• Tools
  • Articles
  • Q&A
  • Login
0 0

pymongo怎么做条件查询?


数据有有title 和intro两个属性,我要做查询,只要title或者intro包含某字符就行,这样怎么写查询语句。

pymongo python mongodb

12 years ago
矿工郑大世

矿工郑大世


share
矿工郑大世 12 years ago

Answers

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/

answered 12 years ago
矿工郑大世

不给力啊老湿


share
不给力啊老湿 answered 12 years ago

Your Answer

Ask Question
Related questions

pymongo中如果读取DBRef关联外键文档字段?

pymongo里,dict存储在list内,如何根据key-value值删除或更新该dict?

MongoDB/Mongoengin 如果设计一个课程表字段

Mongoengine 怎样查询 ListField 里 不包含某个 value 所有结果

求问python下类似SQL中group by的推导?

求 MongoDB 数据分页的实现思路