MCPcopy Create free account
hub / github.com/MongoEngine/mongoengine / update

Method update

mongoengine/base/datastructures.py:332–352  ·  view source on GitHub ↗

Updates the embedded documents with the given replacement values. This function does not support mongoDB update operators such as ``inc__``. .. note:: The embedded document changes are not automatically saved to the database after calling this method

(self, **update)

Source from the content-addressed store, hash-verified

330 return len(values)
331
332 def update(self, **update):
333 """
334 Updates the embedded documents with the given replacement values. This
335 function does not support mongoDB update operators such as ``inc__``.
336
337 .. note::
338 The embedded document changes are not automatically saved
339 to the database after calling this method.
340
341 :param update: A dictionary of update values to apply to each
342 embedded document.
343 :return: The number of entries updated.
344 """
345 if len(update) == 0:
346 return 0
347 values = list(self)
348 for item in values:
349 for k, v in update.items():
350 setattr(item, k, v)
351
352 return len(values)
353
354
355class StrictDict:

Callers 4

__init__Method · 0.45
__new__Method · 0.45
__new__Method · 0.45
merge_index_specsMethod · 0.45

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected