扫码关注官方订阅号
数据有有title 和intro两个属性,我要做查询,只要title或者intro包含某字符就行,这样怎么写查询语句。
认证0级讲师
db.Data.find({ $or: [ { title: {$regex: 'test'} }, { intro: {$regex: 'test'} } ] })
可以参考官方文档: 或查询:http://docs.mongodb.org/manual/reference/operator/query/or/#op._S_or 模糊查询:http://docs.mongodb.org/manual/reference/operator/query/regex/
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
db.Data.find({ $or: [ { title: {$regex: 'test'} }, { intro: {$regex: 'test'} } ] })
可以参考官方文档:
或查询:http://docs.mongodb.org/manual/reference/operator/query/or/#op._S_or
模糊查询:http://docs.mongodb.org/manual/reference/operator/query/regex/