Closed coyksdev closed 6 years ago
Does it throw an error?
it doesn't throw any error it just not update the embedded document
Does it work if you run it without Fawn?
yeah it works when used Model.update() or Model.findOneAndUpdate() in mongoose
I haven't been able to reproduce this issue. Can you provide a running snippet of code with this issue? Thanks.
I'll close this for now. If you're successful in reproducing the issue, feel free to reopen it.
I have the same issue when I try to update the array document It does not throw an error it simply doesn't update
try{ await new Fawn.Task() .update("challenges", {_id: mongoose.Types.ObjectId(req.params.challengeId)}, { $push: { participants: { name: participant.username, profile: participant.profile } } }) .run({useMongoose: true});
}catch(ex){ console.log(ex); }
I'm trying to update one of the embedded document inside the array. when i use na native mongodb command (update) it works but when i use the fawn transaction it is not working.
This is the document in the collection named Post, I want to update the image link by finding the post _id and image _id.
{ "_id": ObjectId("5b0620186ba2be2cb7390e8c"), "type" : "event", "title" : "yeah",
"images" : [ { "_id" : ObjectId("5b061f9f6ba2be2cb7390e8b"), "link" : "this is the link" } ], }
this is my update command
const image = { _id: ObjectId("5b061f9f6ba2be2cb7390e8b"), link: "updated link" }
transaction.update( "Post", { _id: : ObjectId("5b0620186ba2be2cb7390e8c"), 'images._id': ObjectId("5b061f9f6ba2be2cb7390e8b") }, { $set: { 'images.$': { ...image } } } ).run();
it doesn't update the document