Reputation: 63586
UPDATE The query below using $all
works. I've updated the question accordingly.
I have tried this selector:
[ pack "tags" =: [ pack "$all" =: [pack "city", pack "urban"]]]
I have also been able to use the "$xxx"
-like operators for other queries, like the following:
[pack "dueBy" =: [pack "$gt" =: beginningOfTime, pack "$lte" =: readDate stringDate]]
I have a field called "tags"
that is set to have a value that is a list of tags. For example,
["tags" := ["city", "urban", "Rochester"]]
When I construct a selector to retrieve a document from the database based on two tags, I use a selector that looks like this:
[ pack "tags" =: [ pack "$all" =: [pack "city", pack "urban"]]]
Yet when I try to select based on two tags, I get no results. Selecting based on one tag out of many gives me the correct number of results. Also, selecting on one tag and priority (another field) gives me the correct number of results.
Upvotes: 0
Views: 482
Reputation: 13007
Sorry, I don't know Haskell, but in JavaScript this would be:
db.Note.find({tags: {$all: ['school', '229']} });
With $all
you select documents where the array contains all of the values.
Upvotes: 2