The query you want is this:
db.collection.find({"users":{"$not":{"$elemMatch":{"user":{$nin:[1,5,7]}}}}})
This says find me all documents that don’t have elements that are outside of the list 1,5,7.
More Related Contents:
- Does MongoDB’s $in clause guarantee order
- MongoDB aggregation comparison: group(), $group and MapReduce
- Remove Duplicates from MongoDB
- Retrieve only the queried element in an object array in MongoDB collection
- Update MongoDB field using value of another field
- Get names of all keys in the collection
- How to filter array in subdocument with MongoDB [duplicate]
- MongoDB: Combine data from multiple collections into one..how?
- Multiple join conditions using the $lookup operator
- Return only matched sub-document elements within a nested array
- Converting string to date in mongodb
- exclude fields in $lookup aggregation
- Add some kind of row number to a mongodb aggregate command / pipeline
- MongoDB group by array inner-elements
- Mongo sort on a calculated condition
- Find all duplicate documents in a MongoDB collection by a key field
- MongoDB sort documents by array elements
- How to return array of string with mongodb aggregation
- How to return just the nested documents of an array from all documents
- MongoDB: Calculate dwell time between every status value change
- MongoDB: how to parse date in 3.6 mongoDb version?
- Using stored JavaScript functions in the Aggregation pipeline, MapReduce or runCommand
- MongoDB – The argument to $size must be an Array, but was of type: EOO / missing
- convert iso date to timestamp in mongo query
- Using $slice operator to get last element of array
- How to access overall document count during arithmetic aggregation expression
- Mongodb aggregation pipeline how to limit a group push
- Mongodb, aggregate query with $lookup
- mongodb aggregate query isn’t returning proper sum on using $sum
- Return the last “true” value for each group