社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

BenSower

BenSower 最近创建的主题
BenSower 最近回复了
7 年前
回复了 BenSower 创建的主题 » 如何在MongoDB中实现子查询

最简单的方法是使用一个简单的find查询 $gt (greater than) operator 这样地:

db.customers.find({salary: {$gt: 4500}}, {name: 1})

// {salary: {$gt: 4500}} will only return customer documents which have a 'customer.salary' that's greater than 4500 ($gt)
// {name: 1} will create a projection with only the name. (you might have to filter the mandatory _id field, if you only want the name, though.)