You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
可以在数据库中建立字段唯一索引确保数据的唯一性。mongodb建立唯一索引语法:
db.集合名(表名).createIndex({"字段名":1 || -1},{unique:ture});语法中Key值为你要创建的索引字段,1 为指定按升序创建索引,如果你想按降序来创建索引指定为 -1 即可,unique为建立的索引是否唯一,指定为 ture 创建唯一索引,默认值为 false。
Beta Was this translation helpful? Give feedback.
All reactions