There is a limit on the size of the document that can be used in a single command ~16mb so there is a limit on how many inserts you can do via that route.
However, if you use one of the BulkOperationBuilders
released in Casbah 2.7 for MongoDB 2.6 it will automatically split the operation into batches so you can do larger bulk operations:
val collection = MongoClient()("test")("bulkOperation")
collection.drop()
// Ordered bulk operation
val builder = collection.initializeOrderedBulkOperation
builder.insert(MongoDBObject("_id" -> 1))
builder.insert(MongoDBObject("_id" -> 2))
builder.insert(MongoDBObject("_id" -> 3))
builder.find(MongoDBObject("_id" -> 1)).updateOne($set("x" -> 2))
builder.find(MongoDBObject("_id" -> 2)).removeOne()
builder.find(MongoDBObject("_id" -> 3)).replaceOne(MongoDBObject("_id" -> 3, "x" -> 4))
val result = builder.execute()
There are ordered or unordered operations see: http://mongodb.github.io/casbah/whats_new.html#ordered-unordered-bulk-operations