Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set mongo field from variable

Tags:

People also ask

How do I display a specific field in MongoDB?

Use the dot notation to refer to the embedded field in the projection document and set to 0 . Starting in MongoDB 4.4, you can also specify embedded fields using the nested form, e.g. { size: { uom: 0 } } .

Why we use $$ in MongoDB?

$ is referred to the root document fields where as $$ referred to the variable names. Here '$data' is the document array field and the $$currentData is the variable taken in the as expression of $map aggregation.


for(var key in resp.updated_items){
    Meteor.users.update({backend_id: Meteor.user().backend_id},
    {$set: {'profile': {key: resp.updated_items[key]}}});
}

And this query set proper information to key key. But how can I assign 'real' value of key?