Store _Id as object or string in MongoDB?

后端 未结 2 1621
春和景丽
春和景丽 2020-12-08 15:24

I am developing an API using Codeigniter and MongoDB. In this system I am saving the full name and _ID of users that the selected user is following.

What is best to

2条回答
  •  [愿得一人]
    2020-12-08 15:53

    When you use ObjectId, it generates _id as a unique value in all your computers. So if you use Sharding, you will not worry about you _id conflicts. See how ObjectId generates in specification
    But if you use string, you should generate it carefully.

提交回复
热议问题