Reputation: 1401
I'm trying to update an object stored in Mongo that gets created as part of every new users document when they register for my site. By default this object is empty.
How can I push data directly into this object which is within the subfield profile.history.
So far I have been only able to push data into the root of the document itself.
Looking at the image, as stated, I want to write to the history object in profile.
Upvotes: 2
Views: 81
Reputation: 4049
I think you're talking about the Meteor.users collection, below is some code:
let myDynamicField = 'foo'; // Or whatever you want, an input value for example...
let update = {};
update[`profile.history.${myDynamicField1}`] = 'blah';
Meteor.users.update(
{
"_id": "testing123"
},
{
$set: {
update
}
});
*Edited to reflect what the user was asking for in the comments.
Upvotes: 1