insert
On this page本页内容
Summary摘要
Description描述
_id | Document | resumeToken for the resumeAfter parameter when resuming a change stream. resumeAfter参数的resumeToken。_id object has the following form:_id对象具有以下形式:
{
_data type depends on the MongoDB versions and, in some cases, the feature compatibility version (fCV) at the time of the change stream's opening or resumption. _data类型取决于MongoDB版本,在某些情况下,还取决于更改流打开或恢复时的功能兼容性版本(fCV)。_data types._data类型的完整列表。resumeToken, see Resume a Change Stream. resumeToken恢复更改流的示例,请参阅恢复更改流。 |
clusterTime | Timestamp | clusterTime value: the time when the transaction was committed.clusterTime值:事务提交的时间。clusterTime may not all relate to the same transaction. clusterTime的事件可能并不都与同一事务相关。lsid and txnNumber in the change stream event document. lsid和txnNumber的组合。 |
collectionUUID | UUID | UUID |
documentKey | document | _id value of the document created or modified by the CRUD operation._id值的文档。_id field is not repeated if it is already a part of the shard key. _id字段已经是分片键的一部分,则该字段不会重复。 |
fullDocument | document | changeStreamPreAndPostImages option using db.createCollection(), create, or collMod, then the fullDocument field shows the document after it was inserted, replaced, or updated (the document post-image). fullDocument is always included for insert events. db.createCollection()、create或collMod设置changeStreamPreAndPostImages选项,则fullDocument字段将显示插入、替换或更新后的文档(文档后映像)。insert事件始终是包含fullDocument。 |
lsid | document | |
ns | document | |
ns.coll | string | |
ns.db | string | |
operationType | string | insert for these change events. insert值。 |
txnNumber | NumberLong | lsid一起,是一个有助于唯一识别事务的数字。 |
wallTime | ISODate | wallTime differs from clusterTime in that clusterTime is a timestamp taken from the oplog entry associated with the database operation event. wallTime与clusterTime的不同之处在于,clusterTime是从与数据库操作事件关联的oplog条目中获取的时间戳。 |
Example实例
The following example illustrates an 以下示例说明了insert event:insert事件:
{
"_id": { <Resume Token> },
"operationType": "insert",
"clusterTime": <Timestamp>,
"wallTime": <ISODate>,
"ns": {
"db": "engineering",
"coll": "users"
},
"documentKey": {
"userName": "alice123",
"_id": ObjectId("599af247bb69cd89961c986d")
},
"fullDocument": {
"_id": ObjectId("599af247bb69cd89961c986d"),
"userName": "alice123",
"name": "Alice"
}
}
The documentKey field includes both the _id and the userName field. documentKey字段包括_id和userName字段。This indicates that the 这表示engineering.users collection is sharded, with a shard key on userName and _id.engineering.users集合是分片的,在userName和_id上有一个分片键。
The fullDocument document represents the version of the document at the time of the insert.fullDocument文档表示插入时文档的版本。