meteor deletes the rest from subarray while updating

The entry is created like this:

Nodes.insert({name : node1, conf :{flag1: true, flag2: true } });

I wan't to update flag1 from my subarray. This is my code:

Nodes.update(Session.get("node"), {$set:   {conf :{ flag1 : false }}});

When I call the snippet - flag2 gets stripped from my array. I know I could probably add that part into the update notion - but the subarray conf will have lots of entries this could get a bit tedious .. . The order of the flags can change, too. Is there a magic potion for this. The mongodb document is not very clear about this.The conf.$ dot notation throws an error. Thank you for your time.

Answers


You should use $set conf.flag1. Like this:

Nodes.update(Session.get("node"), {$set:   {"conf.flag1" : false}});

The $ positional operator is only used for arrays. Standard dot notation is used for subdocuments.


Need Your Help

Parsing line of text into different variables using php

php arrays parsing

I am very new to php so I apologize for the seemingly simple question. I need to parse a line of text into different variables. More specifically, I need to parse many lines of text in different ar...

Access static variable in symfony 2.2 twig

static twig symfony-2.2

I have a class containing constant options in array form: