问题
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?
回答1:
You are correct in that the bulk API operates on single collections only.
There is no specific reason but the APIs in general are collection-scoped so a "cross-collection bulk insert" would be a design deviation.
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.
来源:https://stackoverflow.com/questions/30952307/mongo-bulk-insert-across-multiple-collections