class Post(Document)
tags = ListField(StringField())
tags 可以是 ["php", "python", "perl"],还可以是 ["ruby", "java"] 之类的
假设,我要列出 tags 里所有不包含 php 的 post,应该怎么写查询?
class Post(Document)
tags = ListField(StringField())
tags 可以是 ["php", "python", "perl"],还可以是 ["ruby", "java"] 之类的
假设,我要列出 tags 里所有不包含 php 的 post,应该怎么写查询?
用 $nin
Consider the following query:
db.inventory.find( { qty: { $nin: [ 5, 15 ] } } )
If the field holds an array, then the $nin operator selects the documents whose field holds an array with no element equal to a value in the specified array (e.g. , , etc.).
2 回答4.3k 阅读✓ 已解决
2 回答867 阅读✓ 已解决
1 回答4.1k 阅读✓ 已解决
3 回答868 阅读✓ 已解决
2 回答2.2k 阅读✓ 已解决
4 回答2.6k 阅读
3 回答912 阅读✓ 已解决
其实就用
$ne
就好了。