I'm having trouble using the $inc operator to update my mongodb collection. To make things simpler, I made a test collection.
My code:
collection.update({field1: 'text'}, { $inc: { items: 5 } }, function (error, result) {
if (error) reject(error);
else resolve(result);
});
My collection:
/* 1 */
{
"_id" : ObjectId("55d2d56a931d867cfeeba4cb"),
"field1" : "text",
"items" : 0
}
The update operation returns no errors, response is OK with 0 updated documents.
What am I doing wrong?
P.S. My mongodb library version is 2.0.39
[edit] I've also tried updateOne method since I saw update is deprecated in version 2, same result though