Details
Description
Basically, there is parsing of the options in the ensureIndex commands but some edge cases need to be ironed out.
dropDups get invoked if ensureIndex options are in array syntax [x=true,y=true]
For example if one inserts
db.test.insert({lname:'David', age:80})
|
db.test.insert({lname:'David', age:80})
|
db.test.insert({lname:'David', age:80})
|
and then issues the command
db.test.ensureIndex({lname:1,age:1},[unique=true,sparse=true])
|
This will drop all of their duplicate data as entered above.
Further, given the parsing of the options as "object" it doesn't matter what 'key' is passed.
db.test.ensureIndex({lname:1,age:1},[x=true,y=true])
|
will yield the same results
However
db.test.ensureIndex({lname:1,age:1},[x=false,y=true])
|
shall yield a more peculiar result - the dropDups will be stored system.indexes but unique won't be enforced.
There may be other ways to pass in these options that can be dangerous in similar ways.