您的位置:首页 > 数据库 > Mongodb

Mongodb查询指定字段方法

2015-12-10 15:13 465 查看
db.getCollection('site_consult_info').find({"status":1,"channels" : { "$in" : [ 2 , 3]} ,

"type" : { "$nin" : [ "yq"]}},{"title":1,"settop_time":1,"pub_time":1}).

sort({ "istop" : -1 , "pub_time" : -1 , "update_time" : -1 , "create_time" : -1})


nin不存在in 存在

db.getCollection(‘集合名称’).find(

{

“status”:1,”channels” : { “in" : [ 2 , 3]} , "type" : { "nin” : [ “yq”]}//查询条件

},

{“title”:1,”settop_time”:1,”pub_time”:1}//指定查询字段 1代表显示该字段

).sort(//排序 desc -1 , asc 1

{ “istop” : -1 , “pub_time” : -1 , “update_time” : -1 , “create_time” : -1}

)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: