I must admit I know of no normal querying method by which to solve this problem. There is only one way I know of and that is to use MongoDBs object comparison. To do this you would change your structure to be something along the lines of:
{
ps: [a,b]
}
or:
{
ps: {p1:a,p2:b}
}
And then you would query like:
db.col.find({ p: [a,b] })
or:
db.col.find({ p: {p1:a, p2:b} })
There is one immedate problem with this though. It is key order dependant which means that if your a
and b
are actually the other way around in another document it won't match. So you will need to make sure you care about order when saving if you do this.
Hope it helps,
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…