Question

I'm trying to figure out how to check if an update succeeded. By default, does db.users.update(....) return a getLastError type? So can I do something like:

error = db.users.update(.....)
if error.n == 1:
  ....

How can I check to make sure that the update succeeded?

Was it helpful?

Solution

pymongo's vague docs say update's return value is:

A document (dict) describing the effect of the update or None if write acknowledgement is disabled.

(Not explicitly stated but) this means that the return value is lastError (unless you use safe=True).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top