这是collection a:
武功:["一阳指","九阴真经","辟邪剑谱"]
collection b:
主要技能: "一阳指",
杀伤力:"90"
这样我前台传来数据{技能:"龙爪手",
杀伤力:"80"}
这个数据既要插入collecttion b
也要把技能:就是龙爪手更新到collection a的"武功"里
类似就b是a的子表
有什么能让他们关联到一起,一次插入而不用一个表一个表的插入。
因为有的字段可能关联多个collection。更新同理
Sorry, original poster, I read it wrong. Mongo does not have such a thing as multi-table transactions. You’d better make it in the form of sub-objects within the table
Python has bulk_write, and most other languages also have it
reqs=[pymongo.DeleteMany (the parameters are actually the same as the delete function), pymongo.UpdateOne (the parameters are actually the same as update_one), pymongo.Insert (same as above)]
database.conns.bulk_write(reqs)
It’s best not to divide the tables. . Mongo’s lock library level