Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{"key":1,"codes":["a","b","c","d"]},{"key":2}]
Query
db.collection.aggregate([{"$match":{"codes":{"$in":["a","b","c"]}}},{"$set":{codes:{$filter:{input:"$codes",as:"c",cond:{$in:["$$c",["a","b","c"]]}}}}}])
Result