struct Mongo::ChangeStream::Document(T)
- Mongo::ChangeStream::Document(T)
- Struct
- Value
- Object
Included Modules
- BSON::Serializable
Defined in:
cryomongo/change_stream.crConstructors
-
.new(bson : BSON)
Allocate an instance and copies data from a BSON struct.
Class Method Summary
-
.from_bson(bson : BSON)
NOTE See
self.new
.
Instance Method Summary
-
#_id : BSON
The id functions as an opaque token for use when resuming an interrupted change stream.
-
#document_key : BSON | Nil
Only present for ops of type ‘insert’, ‘update’, ‘replace’, and ‘delete’.
-
#full_document : T | Nil
Always present for operations of type ‘insert’ and ‘replace’.
-
#ns : BSON
Contains two fields: “db” and “coll” containing the database and collection name in which the change happened.
-
#operation_type : String
Describes the type of operation represented in this change notification.
-
#to_bson(bson = BSON.new)
Converts to a BSON representation.
-
#update_description : UpdateDescription | Nil
Only present for ops of type ‘update’.
Constructor Detail
Allocate an instance and copies data from a BSON struct.
class User
include BSON::Serializable
property name : String
end
data = BSON.new
data["name"] = "John"
User.new(data)
Class Method Detail
Instance Method Detail
The id functions as an opaque token for use when resuming an interrupted change stream.
Only present for ops of type ‘insert’, ‘update’, ‘replace’, and ‘delete’.
For unsharded collections this contains a single field, _id, with the value of the _id of the document updated. For sharded collections, this will contain all the components of the shard key in order, followed by the _id if the _id isn’t part of the shard key.
Always present for operations of type ‘insert’ and ‘replace’. Also present for operations of type ‘update’ if the user has specified ‘updateLookup’ in the ‘fullDocument’ arguments to the ‘$changeStream’ stage.
For operations of type ‘insert’ and ‘replace’, this key will contain the document being inserted, or the new version of the document that is replacing the existing document, respectively.
For operations of type ‘update’, this key will contain a copy of the full version of the document from some point after the update occurred. If the document was deleted since the updated happened, it will be null.
Contains two fields: “db” and “coll” containing the database and collection name in which the change happened.
Describes the type of operation represented in this change notification. "insert" | "update" | "replace" | "delete" | "invalidate" | "drop" | "dropDatabase" | "rename"
Converts to a BSON representation.
user = User.new name: "John"
bson = user.to_bson
Only present for ops of type ‘update’.
Contains a description of updated and removed fields in this operation.