What is the advantage to using an ObjectId instead of, say, a UUID as a plain String?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
An ObjectId is binary, and thus takes up less space. ObjectIds also have the sorting factor--they will end up being in insertion order (or very close), while remaining unique. The sorting can be good for some things, but unwanted for others (like shard keys). You can also extract the timestamp (second resolution) from an ObjectId, which can be convenient.
Aside from that, I would say there's not much difference.