ensure
英[?n'???(r)] US[?n???r]
vt. Ensure; guarantee to obtain [avoid]; make (someone) Get; make safe
index
## English[??ndeks] US[??n?d?ks] n.index;<number>index;instruction; Signvt.Index...;Index...;[Economics]Adjust by living index (wage, price, etc.)vi.[Mechanics]Transposition
MongoDB ensureIndex() method syntax
Function: MongoDB uses the ensureIndex() method to create indexes.
Syntax: >db.COLLECTION_NAME.ensureIndex({KEY:1}) In the syntax, the Key value is the index field you want to create, and 1 specifies to create the index in ascending order. If you If you want to create indexes in descending order, specify -1.
MongoDB ensureIndex() method example
>db.col.ensureIndex({"title":1}) > ensureIndex() 方法中你也可以設(shè)置使用多個(gè)字段創(chuàng)建索引(關(guān)系型數(shù)據(jù)庫(kù)中稱(chēng)作復(fù)合索引)。 >db.col.ensureIndex({"title":1,"description":-1}) >