Linked Questions

6 votes
1 answer
10k views

I am using mongoose.findOneAndUpdate() method for inserting and updating a document in the collection. However if there is nothing to update in the table and a new document is created, the ...
user2498079's user avatar
  • 3,042
0 votes
1 answer
2k views

In MongoDB (using node.js) I want to update a record and then fetch the returned record. Can I do this atomically at all? My searching suggested I could use findOneAndUpdate, however my testing with ...
Kris Randall's user avatar
0 votes
2 answers
2k views

So I have this API method: router.delete('/circleAlertDelete/:id', function(req, res, next){ User.findOne({_id: req.params.id}).then(function(user){ var userTemp = user; var alerts = user....
Ed Lynch's user avatar
  • 623
0 votes
1 answer
953 views

I am working on node js app using express.js and mongodb with mongoose module to handle the database. in one case I need to update a user property languages using findOneAndUpdate method. this ...
Peter Wilson's user avatar
  • 4,317
0 votes
0 answers
457 views

I am a beginner of mongodb and express, now I am trying to update some data. I do not think there is something wrong in my code, when I turn debugging on, the following db operation is printed out and ...
Anna Lee's user avatar
  • 951
0 votes
0 answers
339 views

I have a data similar to this: "_id" : ObjectId("5aff8a15fac9291cb0477c87"), "user" : ObjectId("5adbf5ffd08592252c0efeba"), "createdTime" : ISODate("2018-05-19T02:21:09.943Z"), "...
Kabiru Wahab's user avatar
2 votes
1 answer
109 views

I'm trying to update a specific field in a subdocument based on its Id and the Id of the parent document. I'm new to this so I may be misunderstanding the mongoDb documentation but as far as I can ...
Langdon Froker's user avatar
0 votes
0 answers
114 views

Using Express and MongoDB, how can I update a document, then get that updated document? The following code will find the profile document with the given user.id, then remove the experience with the ...
Ben's user avatar
  • 16.8k
0 votes
0 answers
102 views

I rarely ask someone for help, but in this particular case I can't figure out what to do. I would like to handle PUT requests to my API to update either "name" or "dllFile" or both values in my ...
szakes1's user avatar
  • 914
0 votes
0 answers
84 views

I started working with Mongoose with Express.js. I am trying to insert a record into the database and update it if it exists. I am using findOneAndUpdate for this purpose. But it does not work. Data ...
ashwin mahajan's user avatar
0 votes
0 answers
20 views

i'm using findOneAndUpdate function from mongoose and in the nodejs i am updating a record now i want to send the updated data in response but as mongoose stop supporting callback function in updates ...
Geekyvinayak's user avatar
53 votes
9 answers
27k views

I am using MongoDB with node js , i used npm install mongodb I want to update an existing document and return the updated document , the document is updated correctly . but it returns the old ...
Kanishka Panamaldeniya's user avatar
1 vote
4 answers
2k views

following the official manual, db.students2.findOneAndUpdate( { _id : 1 }, [ { $set: { "total" : { $sum: "$grades.grade" } } } ], // The $set stage is an alias for ``$...
Rahul Dahal's user avatar
0 votes
1 answer
1k views

I have built an API that updates records in MongoDB using mongoose, but currently what happening is if I am passing only 4 field values in the JSON file of postman and try to update then all the ...
Parth Shah's user avatar
0 votes
3 answers
2k views

User is the basic schema I created with a name, email, and password. But when I try to update it no errors occur yet the collection in mongodb doesn't change. Tried the {strict: false} option on the ...
user avatar

15 30 50 per page