开发者

mongo bson objectid

开发者 https://www.devze.com 2023-02-20 05:20 出处:网络
curious what the BSON::ObjectId.id.data array represents? for example [77, 145, 20, 13, 225,开发者_如何学Python 96, 124, 5, 31, 0, 0, 1]BSON::ObjectId.id.data represents 12 bytes of objectId.

curious what the BSON::ObjectId.id.data array represents?

for example [77, 145, 20, 13, 225,开发者_如何学Python 96, 124, 5, 31, 0, 0, 1]


BSON::ObjectId.id.data represents 12 bytes of objectId.
Here's what exactly each byte mean:

0123   456     78   9 10 11
 ^^     ^^     ^^     ^^
time  machine  pid    inc

A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp (seconds since epoch), a 3-byte machine id, a 2-byte process id, and a 3-byte counter. Note that the timestamp and counter fields must be stored big endian unlike the rest of BSON. This is because they are compared byte-by-byte and we want to ensure a mostly increasing order.

ObjectId documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消