I have a document in MongoDB that looks like this:
{ users: ["2", "3", "4"] }
I am trying to query this document by matching an array of users.
db.things.find( { users: { $all: [ "2", "3", "4" ] } } )
This query works, but will also return this document:
{ users: ["2", "3", "4", "5"] }
The last requirement is to be able to query an array of users with elements out of order, say [ "3", "4", "2" ] in the request, and he will be able to return my first document.
Any help would be greatly appreciated. Thanks in advance.
I also use mongoid if it has an assistant that everyone knows about, but can make a direct mongo request if I need to.
source share