美文网首页
MongoDb -索引 + $type + 分析函数 expla

MongoDb -索引 + $type + 分析函数 expla

作者: 泪水渲染眼眶的懵懂_dbb6 | 来源:发表于2017-11-09 15:50 被阅读0次

索引:

db.testCo2.ensureIndex({"name":1}); //普通索引

db.testCo2.reIndex();当前集合的所有index信息

db.testCo2.ensureIndex({“name”:1},{“unique”:true}); //唯一索引:

db.testCo2.getIndexes(); //查询所有的索引

db.testCo2.dropIndex("name_1_age_1"); //删除索引

//使用hint强制要求查询操作使用某个索引

db.testCo2.find({name:"cgh",age:23}).hint({name:1}) //强制使用索引


分析函数:

db.testCo2.find().explain();


$type 字段类型搜索

db.testCo2.find({

"name":{

"$type":10

}});

"_id" :ObjectId("5a03b44e73232118c78f3546"), 

"id" :"221",

"name" : null

}

Double 1

String 2

Object 3

Array 4

Binary data 5

Object id 7

Boolean 8

Date 9

Null 10

Regular expression 11

JavaScript code 13

Symbol 14

JavaScript code with scope 15

32-bit integer 16

Timestamp 17

64-bit integer 18

Min key 255

Max key 127

相关文章

网友评论

      本文标题:MongoDb -索引 + $type + 分析函数 expla

      本文链接:https://www.haomeiwen.com/subject/nttmmxtx.html