You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explicit "action" field in changefeed documents #4194
In changefeed documents, we currently implicitly encode whether they are a deletion, and insertion, an update/replace or an initial result by setting some of old_val and new_val to null or by omitting old_val entirely.
The proposal is to encode this information explicitly by adding an additional field. For example action: 'delete' action: 'insert' action: 'replace' action: 'initial'
Incidentally, our current system also breaks if you have a changefeed like this: r.table('t1')('a').changes()
and you set the value of a to null for a document. The generated change event will be indistinguishable from a deletion. Additionally, when deleting a document that currently has a: null, no change event is generated.
@danielmewes: I'm a fan of this, usually I check for the values of old_val + new_val to infer what happened, but the case you stated is definitely ambiguous!
Mike - I think you are right in terms that it is ambiguous, in the other hand, it is more syntax clear to have the action, for example:
// Currentr.table('t1').changes().run(conn,function(err,cursor){cursor.each(function(n,el){if(el.old_val==null&&el.new_val!=null)// Do something if Inserted// Do somethingelseif(el.old_val!=null&&el.new_val!=null)// Do something if Updated// Do somethingelseif(el.old_val!=null&&el.new_val==null)// Do something if Deleted// Do something});});// If actionr.table('t1').changes().run(conn,function(err,cursor){cursor.each(function(n,el){if(el.action=='Inserted')// Do somethingelseif(el.action=='Updated')// Do somethingelseif(el.action=='Deleted')// Do something});});
Maybe there are more critical features :), so this issue can be made in the future.
@StevenPerez: actually, I was saying that the case @danielmewes stated is ambiguous and is a good reason for adding an action to the changefeed, so we're in agreement:
Incidentally, our current system also breaks if you have a changefeed like this: r.table('t1')('a').changes()
and you set the value of a to null for a document. The generated change event will be indistinguishable from a deletion. Additionally, when deleting a document that currently has a: null, no change event is generated.
Activity
marshall007 commentedon May 7, 2015
I like this a lot! It would allow you to easily filter by the "type" of change being emitted, which is what I was getting at in #3719 (comment).
stevengpa commentedon May 7, 2015
Excellent 👍🏻
Thanks for listen Wise Rethinkdb Partners
mglukhovsky commentedon May 7, 2015
@danielmewes: I'm a fan of this, usually I check for the values of
old_val+new_valto infer what happened, but the case you stated is definitely ambiguous!stevengpa commentedon May 7, 2015
Mike - I think you are right in terms that it is ambiguous, in the other hand, it is more syntax clear to have the action, for example:
Maybe there are more critical features :), so this issue can be made in the future.
mglukhovsky commentedon May 7, 2015
@StevenPerez: actually, I was saying that the case @danielmewes stated is ambiguous and is a good reason for adding an
actionto the changefeed, so we're in agreement:stevengpa commentedon May 7, 2015
Mike - Got it 👍 , sorry It was my bad :) , I'm glad to know you are agree =)
danielmewes commentedon Dec 10, 2015
Merging with #5188