0

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

John
  • 2,107
  • 3
  • 22
  • 39

1 Answers1

1

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

Nicola Iarocci
  • 6,606
  • 1
  • 20
  • 33