Should I use string or objectid for non-primary key IDs in mongodb?
过去多啦不再A梦
过去多啦不再A梦 2017-05-02 09:25:26
0
3
734
{
    _id:ObjectId,
    otherID:String
}
{
    _id:ObjectId,
    OtherID:ObjectId
}

What’s the difference?

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
曾经蜡笔没有小新

Please use ObjectId, various operations are more convenient than strings

过去多啦不再A梦

I have made a more comprehensive explanation about ObjectId, you can refer to the article.
If you don’t want to read it all, the answer to this question is in the Q&A section at the end.

洪涛

ObjectId is easier to generate in a sharded environment... and the default _id key is an ObjectId object..

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template