<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, fields, cond=None, doc_ids=None, eids=None):
 """ Update all matching documents to have a given set of fields. :param fields: the fields that the matching documents will have or a method that will update the documents :type fields: dict | dict -> None :param cond: which documents to update :type cond: query :param doc_ids: a list of document IDs :type doc_ids: list :returns: a list containing the updated document's ID """

        doc_ids = _get_doc_ids(doc_ids, eids)

        if callable(fields):
            return self.process_elements(
                lambda data, doc_id: fields(data[doc_id]),
                cond, doc_ids
            )
        else:
            return self.process_elements(
                lambda data, doc_id: data[doc_id].update(fields),
                cond, doc_ids
            )