Pergunta

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?

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top