// 查询 user_id 是否存在
db.getCollection("t_mongo_user").find({"user_id" : { $exists: true }})
// 查询 user_id = 10 的记录
db.getCollection("t_mongo_user").find({"user_id" : 10})
// 排序 -1,按照 _id 倒排;1,按照 _id 正排
db.getCollection("t_mongo_user").find({}).sort({"_id" : -1})
// 查看索引
db.getCollection("t_mongo_user_message").getIndexes();
// 创建索引
db.t_mongo_user.createIndex({"user_id":1}, {background:true})
// 删除索引
db.t_mongo_user.dropIndex("idx_user_id")
// 创建分片
sh.shardCollection("mongo.t_mongo_user", { "user_id" : "hashed" });
// 创建集合
db.createCollection("t_mongo_user");
// 删除集合
db.t_mongo_user.drop();
// 创建唯一索引
db.getCollection("t_mongo_user").createIndex({"user_id": 1
}, {name: "idx_userId",background: true,unique: true
});