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?

有帮助吗?

解决方案

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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top