Closed stasKaufman closed 6 years ago
Hello,
I have two collections "bills" and "items"
example:
bills: { "_id" : ObjectId("5a27ea8285531a175c6d104c"), "updatedAt" : ISODate("2017-12-14T20:02:44.225Z"), "created_at" : ISODate("2017-12-06T13:02:58.812Z"), "employee" : ObjectId("5a26c16c9d13bf146029e08b"), "status" : "open", "items" : [ { "item" : ObjectId("5a272bec4db117287b2251bd"), "_id" : ObjectId("5a293e956df8110f80cc07f8"), "amount" : 9 } ], "__v" : 20 }
items: { "_id" : ObjectId("5a272bec4db117287b2251bd"), "name" : "beer", "price" : 5, "description" : "some description", "amount" : 3 }
This query only update the "items" collection
return task.update("bills", {'items.item': itemID}, {$inc: {'items.$.amount': 1}}) .update("items", {_id: item._id}, {$inc: {amount: -1}}).run();
I tested those queries separately and the syntax is fine and it works.
Is they some issue with "Fawn" and maybe embedded arrays ?
I'll look into this and get back to you
Upgrade your version of Fawn and it should work. Feel free to reopen this issue if it persists
Hello,
I have two collections "bills" and "items"
example:
bills: { "_id" : ObjectId("5a27ea8285531a175c6d104c"), "updatedAt" : ISODate("2017-12-14T20:02:44.225Z"), "created_at" : ISODate("2017-12-06T13:02:58.812Z"), "employee" : ObjectId("5a26c16c9d13bf146029e08b"), "status" : "open", "items" : [ { "item" : ObjectId("5a272bec4db117287b2251bd"), "_id" : ObjectId("5a293e956df8110f80cc07f8"), "amount" : 9 } ], "__v" : 20 }
items: { "_id" : ObjectId("5a272bec4db117287b2251bd"), "name" : "beer", "price" : 5, "description" : "some description", "amount" : 3 }
This query only update the "items" collection
return task.update("bills", {'items.item': itemID}, {$inc: {'items.$.amount': 1}}) .update("items", {_id: item._id}, {$inc: {amount: -1}}).run();
I tested those queries separately and the syntax is fine and it works.
Is they some issue with "Fawn" and maybe embedded arrays ?