I'm trying to get mongodb query working. Collection comes in the format:
{
"_id": {
"$oid": "54651022bffebc03098b4567"
},
"browser": "ie",
"browser_version": "10.0 Desktop",
"os_version": "8",
"device": null,
"os": "Windows"
}
The following works:
{
"_id": {
"$in": [
{
"$oid": "54651022bffebc03098b4567"
},
{
"$oid": "54651022bffebc03098b4568"
}
]
}
}
However, I get a syntax error for the following:
{
"_id": {
"$in": [
ObjectId("54651022bffebc03098b4567"),
ObjectId("54651022bffebc03098b4568")
]
}
}
There are a similar questions that suggested that ObjectId should work:
How to create query with ObjectIds using java?
$all parameter in mongodb does not work with ObjectId list
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…