Collection indexes can be specified with index builder that provides simple expressive syntax.
Index examples (assuming `import collection.Order._`):
index("foo" -> Ascending)
({ "foo" : 1},{ })index("foo" -> Ascending, "boo" -> Descending)
({ "foo" : 1 , "boo" : -1},{ })index("foo" -> Ascending).background(true)
({ "foo" : 1},{ "background" : true})index("foo" -> Ascending).unique(true)
({ "foo" : 1},{ "unique" : true})index("foo" -> Ascending).name("indexName")
({ "foo" : 1},{ "name" : "indexName"})index("foo" -> Ascending).dropDups(true)
({ "foo" : 1},{ "dropDups" : true})index("foo" -> Ascending).sparse(true)
({ "foo" : 1},{ "sparse" : true})index("foo" -> Ascending).expireAfterSeconds(10)
({ "foo" : 1},{ "expireAfterSeconds" : 10})index("foo" -> Ascending).version(1)
({ "foo" : 1},{ "v" : 1})index("foo" -> Ascending).weights("items" -> 2)
({ "foo" : 1},{ "weights" : { "items" : 2}})index("foo" -> Ascending).defaultLanguage("english")
({ "foo" : 1},{ "defaultLanguage" : "english"})index("foo" -> Ascending).languageOverride("english")
({ "foo" : 1},{ "languageOverride" : "english"})index("foo" -> Ascending).sparse(true).unique(true).name("indexName")
({ "foo" : 1},{ "sparse" : true , "unique" : true , "name" : "indexName"})Total for specification IndexBuilderSpec | |
---|---|
Finished in | 39 ms |
Results | 13 examples, 0 failure, 0 error |