Server side script updating value

Hi All

If the record in the child table exists, I’d like to update some values with the help of server side script I’d like to update it - I’m struggling in updating the child table value which is already exists in the another doctypes child table.
And if records are not found then add that records in child table.