I'm digging around a MongoDB oplog, and I'm wanting to look at all operations that match the following:
"o" : {
"$set" : {
"skus.0.stock" : 1
}
}
The operation in question updates an object similar to this:
{
skus: [
{
stock: Number
},
{
stock: Number
},
]
}
The above oplog operation is $set
ing the stock level of an object on the skus array.
The problem is when I execute .find({"o.$set.skus.0.stock": {$exists: true}})
I get nothing back. mongo shell is expecting an object that looks like this:
"o" : {
"$set" : {
"skus" : {
"0": {
stock" : 1
}
}
}
}
I took a look at this question, but the top answer basically just substitutes the period for a similar unicode character. In this case, the oplog has already inserted an actual period in to the field name.
Bracket notation throws an error a syntax error without quotes, and doesn't return anything with quotes (it just doesn't work.)