MongoDB query an array for an exact element match, but may be out of order
问题 I have a document in MongoDB that looks like this: { users: ["2", "3", "4"] } I'm try to query this document by matching the users array. db.things.find( { users: { $all: [ "2", "3", "4" ] } } ) That query works, but would also return this document: { users: ["2", "3", "4", "5"] } Last requirement is to be able to query the users array with the elements out of order, say [ "3", "4", "2" ] in the query, and it be able to return my first document listed. Any help would be greatly appreciated.