Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top