, a
, .getIndexes()
> db.collection.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "test.collection"
},
{
"v" : 1,
"unique" : true,
"key" : {
"a" : 1
},
"name" : "a_1",
"ns" : "test.collection"
}
]
:
var docs = [ { 'a': 3 }, { 'a': 4 }, { 'a': 3 } ];
Bulk()
API , , MongoDB , .
var docs = [{a: 3}, {a: 4}, {a: 3}]
var bulk = db.collection.initializeUnorderedBulkOp();
for(var ind=0; ind<docs.length; ind++) {
bulk.insert(docs[ind]);
}
bulk.execute();
, .
, bulk.execute()
db.collection.find()
:
{ "_id" : ObjectId("5629c5d1e6d6a6b8e38d013c"), "a" : 3 }
{ "_id" : ObjectId("5629c5d1e6d6a6b8e38d013d"), "a" : 4 }