问题描述
我看到mongo具有批量插入,但是我看到了没有能力在多个集合之间进行批量插入.由于我在任何地方都看不到它,因此我假设它在Mongo中不可用.有什么具体原因吗?
I see that mongo has bulk insert, but I see nowhere the capability to do bulk inserts across multiple collections.Since I do not see it anywhere I'm assuming its not available from Mongo. Any specific reason for that?
推荐答案
您是正确的,因为批量API仅在单个集合上运行.
You are correct in that the bulk API operates on single collections only.
没有特殊原因,但API通常是基于集合范围的,因此跨集合批量插入"将是设计偏差.
There is no specific reason but the APIs in general are collection-scoped so a "cross-collection bulk insert" would be a design deviation.
您当然可以在一个程序中设置多个批量API对象,每个对象位于不同的集合中.请记住,尽管这不是事务性的(从startTrans-commit-rollback的意义上来说),批量插入也不是事务性的.
You can of course set up multiple bulk API objects in a program, each on a different collection. Keep in mind that while this wouldn't be transactional (in the startTrans-commit-rollback sense), neither is bulk insert.
这篇关于跨多个集合的Mongo批量插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!