Pregunta

I understand we have a on_insert_resources event that is triggered once a post is sent to python-eve, but this is before the document is saved onto mongodb, is it possible to get a hook after the document is saved? (I need to populate some of the field according to it ID that is generated by mongodb) thanks

¿Fue útil?

Solución

It looks like the Post-Request hooks would do the trick for you. Something like so:

>>> def update_docs(resource, request, payload):
...     """ do your stuff here """
...     pass

>>> app = Eve()

>>> app.on_post_POST += udpate_docs
>>> app.run()

payload contains the response stream which includes all the document unique ids and the other metatags (_etag, etc.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top