MongoDB
 SQL >> Base de Dados >  >> NoSQL >> MongoDB

MongoDB: correspondência de múltiplos elementos de array

Use $all:

db.MyCollection.find({
  Location: { "$within": { "$center": [[1, 1], 5] } },
  Properties: { $all: [ { $elemMatch: { Type: 1, Value: "a" } }, { $elemMatch: { Type: 2, Value: "b" } } ] }
});

Sem $all, use $and com dois $elemMatch.