就是有2个集合,然后2个集合同时插入数据。希望数据的_id是一样的。我插入的时候老是相差1。想问怎么实现,谢谢了
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
Before inserting data, use _id = ObjectId() to generate the id and put it into two dicts, then perform the save action
The writing below shell is
var id = new ObjectId(); db.coll_1.insert({ _id: id, ... // 其他字段 }) db.coll_2.insert({ _id: id, ... // 其他字段 })
In short, just make a new oneObjectId by yourself.
ObjectId
Before inserting data, use _id = ObjectId() to generate the id and put it into two dicts, then perform the save action
The writing below shell is
In short, just make a new one
ObjectId
by yourself.