: securityIndex v.0.0.0
https://docs.mongodb.com/manual/reference/method/db.collection.ensureIndex/
as-is ( ensure create - ), db.products.ensureIndex db.products.createIndex.
.
:
db.products.ensureIndex({ url: 1 }, { unique: true, background: true, dropDups: true })
db.products.insert(
[{ imagename: "pen", qty: 21 },
{ imagename: "pen", qty: 20 },
{ imagename: "eraser", qty: 25 }],
{ ordered: false }
)
: E11000 : mongotest.products: imagename_1 dup key: {: 'pen'}.
.
... catche
try {
db.products.insert(
[{ imagename: "pen", qty: 21 },
{ imagename: "pen", qty: 20 },
{ imagename: "eraser", qty: 25 }],
{ ordered: false }
)
}catch(e){
print(e)
}
: secureIndex, insert.because. makeIndex , securityIndex .