<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update(self, instance):
 """ method finds unit_of_work record and change its status"""

        assert isinstance(instance, UnitOfWork)
        if instance.db_id:
            query = {'_id': ObjectId(instance.db_id)}
        else:
            query = {unit_of_work.PROCESS_NAME: instance.process_name,
                     unit_of_work.TIMEPERIOD: instance.timeperiod,
                     unit_of_work.START_ID: instance.start_id,
                     unit_of_work.END_ID: instance.end_id}
        self.ds.update(COLLECTION_UNIT_OF_WORK, query, instance)
        return instance.db_id