Linked Questions
170 questions linked to/from Update MongoDB field using value of another field
79
votes
6
answers
71k
views
MongoDB: Updating documents using data from the same document [duplicate]
I have a list of documents, each with lat and lon properties (among others).
{ 'lat': 1, 'lon': 2, someotherdata [...] }
{ 'lat': 4, 'lon': 1, someotherdata [...] }
[...]
I want to modify it so that ...
29
votes
3
answers
38k
views
Update field with another field's value in the document [duplicate]
I have a collection t1 with the following fields in its schema
_id, field1, field1
I want set field2's value field1 like sql:
update t1 set field1=field2;
How do I do it in MongoDB?
4
votes
1
answer
17k
views
MongoDB : how to set a new field equal to the value of another field, for every document in a collection [duplicate]
I need to run a migration script to insert a value (already available in each document) into an array of this same document. This has to be done for each documents of my collection (no selection query ...
1
vote
1
answer
6k
views
Mongoose findOneAndUpdate - update one field using another [duplicate]
Consider this schema:
var UserSchema = new Schema({
...
user_id: {type:String},
previous_selection: {type:String},
current_selection: {type:String}
});
I need to write a function, ...
4
votes
1
answer
5k
views
MongoDB $set in aggregate [duplicate]
I want to set the value of a new field in every document of a "destination" collection, based on the value of a field in documents of another "source" collection.
Documents of the destination ...
2
votes
2
answers
5k
views
How to update a field using its previous value in MongoDB/Mongoose [duplicate]
I know I can do an update using $set:
Contact.update({
_id: request.id
}, {
$set: { name: newNameValue }
}, {
upsert: false
}, function(err) { ... });
But in this case, instead of passing ...
1
vote
3
answers
1k
views
PyMongo - Setting all values in an attribute to lowercase [duplicate]
I am cleaning a dataset, and have a field gender. In this field, there are entries such as Male, male, and MALE. To resolve this, I am trying to update my MongoDB database using pymongo.
In the ...
1
vote
1
answer
4k
views
How to change date and time in MongoDB? [duplicate]
I have the DB with names and dates. I need to change the old date with the date that is +3 days after that. For example oldaDate is 01.02.2015 the new one is 03.02.2015.
I was trying just to put ...
2
votes
1
answer
3k
views
Update specific field in all documents in MongoDB [duplicate]
I have a collection in MongoDB that contains a list of objects. Each object has an array of "updaters" which are objects with a field that I want to update. One of the updaters in that array needs a ...
1
vote
1
answer
2k
views
How do I convert string to ISODate and Time in MongoDB using Python? [duplicate]
I am new to MongoDB and Python thus struggling with something that I'm sure is quite simple to do. In my collection (sample below), I have the date and time stored as a string. I need to convert them ...
5
votes
3
answers
2k
views
Add new field which is the size of another field of the document [duplicate]
I am new to MongoDB and I would like to ask how to make a new field for the element, which represents for the size of another field in that element. For example:
- I have the element such like:
{
"...
1
vote
1
answer
3k
views
MongoDB update query: field to be the sum of other fields [duplicate]
I have an inner array as the following:
[
{'name': 'foo', 'size': 1},
{'name': 'baz', 'size': 2},
/* ... */
]
I'd like to update some outer field, total which is the sum of all sizes, ...
2
votes
0
answers
3k
views
mongodb update query to append a data to already existing field [duplicate]
For a web application form i'm trying to add data to mongo collection on click of submit. my mongo collection is as below :
collection1:
{ "_id" : ObjectId("56e0a3a2d59feaa43fba49d5"), "timestamp" :...
5
votes
1
answer
1k
views
PyMongo: How To Update A Collection Using Aggregate? [duplicate]
This is a continuation of this question.
I'm using the following code to find all documents from collection C_a whose text contains the word StackOverflow and store them in another collection called ...
1
vote
1
answer
1k
views
How to update MongoDB field using value of another field [duplicate]
Is it possible to update a field using the value of another field?
Here is my schema
var timeSchema = new mongoose.Schema({
hours: Number,
minutes: Number
});
module.exports = mongoose....