I have a use-case where there is a modified (time stamp) in all documents of a table. Each time I update a document I also update that modified field.
Thing is that when having a changefeed on this table I usually isn't particularly interested in _when_ the modified field has changed, _but_ I'd still like it to be included in the changefeed.
Of course, a simple work-around is to return the primary key in the query and then do an additional get-query the retrieve the modified field.
Perhaps a simple variant could be to explicitly ignore changes to some fields with an optional argument to changes():
table.pluck('important_info', 'modified').changes(ignore=['modified'])
You could try this query to post-filter changes where the only difference is in the modified field:
table.pluck('important_info', 'modified').changes().filter(
r.branch(r.row.hasFields("old_val", "new_val"),
r.row("old_val").without("modified").ne(r.row("new_val").without("modified")),
true)
)
Uhm, now I feel a bit stupid. I thought changes() had to be last in a query...
Well then, that opens up new possibilities! Thanks!
Ok maybe not close it. I'll give your suggestion a go first 馃槂
@tatsujin1 It's pretty non-obvious to notice, since it's usually not necessary to put things behind the changes() and putting them in front of it often provides better performance since the filtering can happen earlier. But for special cases like this it can be useful :-)
Awesome, works just like I wanted it to :)
It took a few seconds to understand the filter-branch interaction, though...
Thanks again!
Most helpful comment
You could try this query to post-filter changes where the only difference is in the
modifiedfield: