I'm trying to learn how to use the lambda function to resolve conflicts when inserting into a table with rethinkdb
and python
, like the last example on this page. I would like to compare a timestamp
field between the old_doc
and new_doc
and keep the more recent document.
r.table(import_table).insert(documents, conflict=lambda id, old_doc, new_doc: new_doc if new_doc['timestamp'] > old_doc['timestamp'] else old_doc).run()```
This gives the following error
rethinkdb.errors.ReqlQueryLogicError: Expected type DATUM but found FUNCTION
I can't find much documentation on this error or using lambda functions for conflict resolution. Running something simpler like:
r.table(import_table).insert(documents, conflict=lambda id, old_doc, new_doc: new_doc).run()
gives the same error which makes me think that I'm not writing this correctly. Any help would be appreciated.