数据库管理mongodb select

涵盖了如何为您的应用程序用户创建搜索体验 , 并指导您了解聚合、索引、数据建模和事务等关键主题

select

select * from zips limt 1 ; 

select city , state from zips limit 1 ; 

完整说明

db.collection.findOne(filter,projection,options)

简短

db.zips.findOne({})

回传json格式数据

select city from zips where state = 'AZ' and pop < 500 ; 
db.zips.find({state: 'AZ', pop: {$lt: 500}})
EXPLAIN SELECT city, state, pop 
            FROM zips 
WHERE state = 'NY' AND pop BETWEEN 1000 AND 5000 
ORDER BY pop DESC 
LIMIT 10;
db.zips.explain().find(
    { state: "NY", pop: { $gte: 1000, $lte: 5000 }}, 
    {_id: 0, state: 1, city: 1, pop: 1}
    ).sort({pop: -1})
    .limit(10)