I've a little question about a rethinkdb request in python.
I've a nested document like this:
{'id': XX, 'markets_tracking': {'market_name_1': { 'latest_update': (timestamp), 'market_data': { 'type_1': {'place1': XX, 'place2': XX}, {'type_2': {'place1':XX, 'place2': XX}}}}}}
This document is updated very often(between 500ms and 2-3s) by one or more workers. It's the place values which are updated for a specific type. To be sure to have the most recent value inserted, I want to perform a check on the field 'lastest_update'(to be sure that my new value extracted is more recent than the value in rethinkdb) before updated it the place value and at the same time if I update it, I want to update the lastest_update value...
Currently, I was able to create a conditional update like this:
r.table('markets_us').get('xxx').update(lambda market: r.branch(market['market_tracking']['market_name_1']['latest_update'] < time.time(), {'market_tracking':{'type_1':{'place1':XX}}}, {})).run()
And now I just need to add an update of the field 'latest-update' at the same time, if it's possible..
Thanks,