Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo Bulk Insert across multiple collections

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?

like image 320
Neil Avatar asked Jun 20 '15 09:06

Neil


1 Answers

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.

like image 198
Buzz Moschetti Avatar answered Oct 23 '22 12:10

Buzz Moschetti