Skip to main content

All Questions

2 votes
1 answer
480 views

UpdateMany document with array of objects in mongodb

I have a mongodb collection which looks like this [ { pId: "p1", apikey: "a2", count: 0 }, { pId: "p2", apikey: "...
abinas patra's user avatar
0 votes
1 answer
36 views

problems to update mongodb collection

so I have two different collections for my social media app. One for the users and the other one for the user's posts. Whenever I'm updating the info from one of my user's collection it should also ...
dylanb15's user avatar
1 vote
1 answer
31 views

Unable to update data values on mongoDb native findOneAndUpdate query

exports.update_activity_status = (req, res) => { const { campaign_id, leadId, leadActivity, status, } = req.body; const client = mongoClient.connect(`${process.env.MONGO_URL}`...
program_bumble_bee's user avatar
1 vote
1 answer
55 views

Remove (Update query) only particular element in array of array mongodb?

My Input Data { _id: 1, results: [ { item: "A", score: 5, answers: [ { q: 1, a: 4 }, { q: 2, a: 6 } ] }, { item: "B", score: 8, answers: [ { q: 1, a: 8 }, { q: 2, a: 9 } ] } ] } ...
Arun's user avatar
  • 21
1 vote
1 answer
3k views

how do I fix this problem I'm having with findOneAndUpdate

Trying to update mongodb doc using findOneAndUpdate method tried looking up the doc in various ways and reformating the update in different ways router.put( "/edit", [ auth, [ ...
Ggd Hhdhd's user avatar
  • 145
1 vote
1 answer
33 views

Using Javascript arrray in mongodb update query with $in

I am trying to update all documents in my collection which have fields containing any one of the values in my javascript array. I keep getting a '$in needs an array' error. I do not understand how to ...
Abhishek Malik's user avatar
0 votes
1 answer
241 views

Right usage of MongoDB update functions in Javascript

I have a probably simple problem using the MongoDB API for updating a document. I have tried several things but nothing was successful. Inserting and deleting in contrast work fine. So what am I ...
user2442635's user avatar
2 votes
2 answers
3k views

How to get update query WriteResult in mongodb

I am doing an update in mongodb but not very familiar with how to get things done in mongodb. Todo.update({}, {$set : { tags : []}}, false, true); How do I get WriteResult? I want to know the ...
jsbisht's user avatar
  • 9,417
0 votes
1 answer
300 views

mongodb: matching an element in an array and updating

Basically, I have done aggregation to get the total and the list of objects that formed the total. Now, I have to update the source table with aggregated object id for the elements that contribute ...
user3639648's user avatar
0 votes
2 answers
5k views

Update a field, depending on another field, in MongoDB documents (with Mongoose in Node.js)

I have a collection named Article in MongoDB database, with the following schema and model: var articleSchema = new Schema({ site: String, date: String, day: String, link: { type: ...
GBC's user avatar
  • 345
12 votes
3 answers
27k views

Add a field to existing MongoDB document (with Mongoose in Node.js)

I have this existing document in a collection Article in MongoDB database: [ { site: 'www.atlantico.fr', date: '2014-05-27T11:10:19.000Z', link: 'http://www.atlantico.fr/example.html', _id: ...
GBC's user avatar
  • 345