malc_b
Coder
Working on a little project that has me using a number of thing for the first time. One of these is Mongo. Looking to replace a document in a collection by using the Mongo assigned Id. Problem is that I don't ever seem to get a matched record no matter what I do despite the fact the ID exists. The code I've got so far is:
database is defined correctly and it has no problems finding it or the collection. The req.body.id is just the string for the id (ie 62976f1c4dd4127c772e27cd) not the whole ObjectId part of it. I've tried putting together a full string and a query string but each time no match. Seeing as I've been at this waaaaay too long already I was hoping somone may be able to help. Thanks.
Code:
database.collection("pid").replaceOne(
{_id : req.body.id},
req.body,
{}
)
database is defined correctly and it has no problems finding it or the collection. The req.body.id is just the string for the id (ie 62976f1c4dd4127c772e27cd) not the whole ObjectId part of it. I've tried putting together a full string and a query string but each time no match. Seeing as I've been at this waaaaay too long already I was hoping somone may be able to help. Thanks.