I want to perform a $pull
update operation on votes array in the following document
{ _id: 1, votes: [ 3, 5, 6, 7, 7, 8 ], threshold : 5 }
for which I used the following query
db.values.update({_id:1},{$pull:{votes:{$lt:"$threshold"}}},{})
This query doesn't seem to work if try to access threshold dynamically. If I try to use {$lt:5}
, it works, but that beats my purpose.
I expect this to return the following document
{ _id: 1, votes: [ 5, 6, 7, 7, 8 ], threshold : 5 }
Is there a way that this could be done without changing the structure of my json or creating any additional fields?