<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, item, id_expression=None, upsert=False, update_ops={}, safe=None, **kwargs):
		''' Update an item in the database.  Uses the on_update keyword to each
			field to decide which operations to do, or.

			:param item: An instance of a :class:`~ommongo.document.Document` \
				subclass
			:param id_expression: A query expression that uniquely picks out \
				the item which should be updated.  If id_expression is not \
				passed, update uses item.mongo_id.
			:param upsert: Whether the update operation should be an upsert. \
				If the item may not be in the database yet this should be True
			:param update_ops: By default the operation used to update a field \
				is specified with the on_update argument to its constructor. \
				To override that value, use this dictionary, with  \
				:class:`~ommongo.document.QueryField` objects as the keys \
				and the mongo operation to use as the values.
			:param kwargs: The kwargs are merged into update_ops dict to \
				decide which fields to update the operation for.  These can \
				only be for the top-level document since the keys \
				are just strings.

			.. warning::

				This operation is **experimental** and **not fully tested**,
				although it does have code coverage.
			'''
		if safe is None:
			safe = self.safe
		self.queue.append(UpdateDocumentOp(self.transaction_id, self, item, safe, id_expression=id_expression,
						  upsert=upsert, update_ops=update_ops, **kwargs))
		if self.autoflush:
			return self.flush()