3.6 Change Streams updateDescription.updatedFields

200 views
Skip to first unread message

Kevin Fairclough

unread,
Feb 1, 2018, 10:23:26 AM2/1/18
to mongodb-user
Change streams, update event.

Is the format for updateDescription.updatedFields the same as the format you would provide to a $set operation?

i.e. could i take the document and update a copy of the document by using  { $set: updateDescription.updatedFields}
Similarly with the updateDescription.removedFields although i noticed that is an array so I guess I'll have to construct $unset manually.

Thanks
Kevin

Wan Bachtiar

unread,
Feb 27, 2018, 11:10:01 PM2/27/18
to mongodb-user

Is the format for updateDescription.updatedFields the same as the format you would provide to a $set operation?

Hi Kevin,

The format would be the same as what $set operation would accept. For example if you have a database update operation as below:

db.collection.update({"_id":101}, {"$set":{"x":{"a":1, "b":1, "c":1}}})

the value of document output for the change event would be:

{   '_id': {   '_data': '',
               '_typeBits': b'\x01'},
    'documentKey': {'_id': 101.0},
    'fullDocument': {   '_id': 101.0,
                        'x': {'a': 1.0, 'b': 1.0, 'c': 1.0}},
    'ns': {'coll': 'collection', 'db': 'database'},
    'operationType': 'update',
    'updateDescription': {   'removedFields': [],
                             'updatedFields': {   'x': {   'a': 1.0,
                                                           'b': 1.0,
                                                           'c': 1.0}}}}

See also Change Streams and Change Stream Examples

Regards,
Wan.

Kevin Fairclough

unread,
Feb 28, 2018, 9:22:16 AM2/28/18
to mongod...@googlegroups.com
Thanks
Wan

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/4Ayc73sOJkk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/3df23fcb-d7a3-4c53-b138-db7d1acf4ec8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages