mongodb query subset of an array

后端 未结 3 1265
清酒与你
清酒与你 2021-02-06 10:03

I have a field _keywords which is an array of strings. I want to get documents of which _keywords are super-set of the query array.

For example

3条回答
  •  故里飘歌
    2021-02-06 10:55

    Use the $all operator:

    db.article.find( { _keywords: { $all: [ 'foo1', 'foo2' ] } } );
    

    Source: http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24all

提交回复
热议问题