超时索引
db.ShortMessageCode.createIndex( { "createDateTTL": 1 }, { expireAfterSeconds: 300 } )
唯一索引并去重
db.Domain.createIndex( { "domain": 1 }, {unique:true,dropDups:true} )
本文介绍 MongoDB 中两种特殊的索引类型:超时索引和唯一去重索引。超时索引用于自动删除过期的数据记录,而唯一去重索引则确保集合中的特定字段具有唯一性且不会重复插入相同的值。
超时索引
db.ShortMessageCode.createIndex( { "createDateTTL": 1 }, { expireAfterSeconds: 300 } )
唯一索引并去重
db.Domain.createIndex( { "domain": 1 }, {unique:true,dropDups:true} )
1272

被折叠的 条评论
为什么被折叠?