How to update a mongodb collection
See original GitHub issueI have the following code:
exports.up = function(db, callback) {
db.createCollection('table', function() {
db.insert('table', {
name: 'micha'
}, function() {
db.update('table', {
name: 'cedric',
surname: 'camelot'
}, {
name: 'micha'
}, callback);
});
});
};
Baiscly what i want is to update specific fields.
What iam getting is:
[ERROR] TypeError: db.update is not a function
<bountysource-plugin>
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/39613002-how-to-update-a-mongodb-collection?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github).
</bountysource-plugin>Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
db.collection.update() — MongoDB Manual
By default, the db.collection.update() method updates a single document. Include the option multi: true to update all documents that match the query ...
Read more >MongoDB - Update Document - Tutorialspoint
MongoDB's update () and save() methods are used to update document into a collection. The update() method updates the values in the existing...
Read more >MongoDB Update() Document with Example - Guru99
MongoDB provides the update() command to update the documents of a collection. To update only the documents you want to update, ...
Read more >MongoDB Update Document with Examples - Simplilearn
To update a document in MongoDB, we use the update() method. The update() method refreshes the values in a MongoDB collection's existing ...
Read more >How to update a collection in mongodb - Stack Overflow
4 · db.collection ; 1 · db.mycollection ; 0 · db.<collection_name>.update ; -2 · db.<collection_name>.update ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wzrdtales why not simply pass mongodb driver as argument to up/down functions ? In the moment I should use
_run
that get access to most api of mongodb driver. This is very strange.@BorntraegerMarc Thanks for hitting me up again, things can get lost quite quickly. I often read issues but have no time to immediately answer them. Later they do not pop up again in the notifications though. It is never bad to just ping me up once again, to make me notice 😃
@lampe There is a theoretical implementation already there though. Although it is not available on the public api: https://github.com/db-migrate/mongodb/blob/master/index.js#L432
You could however currently run
_run
directly with ‘update’ as first argument, see https://github.com/db-migrate/mongodb/blob/master/index.js#L260