Edit object in sub of sub array in MongoDB -


I need all array sub-updates in MongoDB. "Flavio", "desc": "feature", "my name": "<" America: "[[" _ id ": ObjectId (" 543ebeb473bc8d243d6b28dc ")," name ":" asdf "," desc ":" asdf "," work ": [{" _ id ": ObjectId (" 544029257266e4841735cde8 ") , "Name": "hello", "date": "16/10/2014 17:23:01", "author": "5424ac37eb0ea85d4c921f8b"}, {"_ id": ObjectId ("54410bf33561315021a29e2b"), "name ":" Lol "," date ":" 17/10/2014 09: 30:43 am "," author ":" 5424ac37eb0ea85d4c921f8b "}]}]}

The task will push a new array for the task _ id = ObjectId ("54410bf33561315021a29e2b")

Expected the job to be updated:. ("54410bf33561315021a29e2b"), "name": "lol", "date": "17/10/2014 09:30:43 am", " Writer ":" 5424ac37eb0ea85d4c921f8b "" Points ": [{" Count ": 10," Name ":" pt "}]}

I was trying with:

  db.projects.update ({"US.tasks": {$ elemMatch: {"_ id": ObjectId ("544029257266e4841735cde8"}}}}, {$ Push: {"US $. ": {" Points ": []}}} db.projects.update ({" US.tasks ": {$ elem match: {" _id ": ObjectId (" 544029257266e4841735cde8 "}}}}, {$ push: {"US $ tasks.points ..": {"Count": 10, "name": "pt"}}})   

but new objects are not entered in the task object .

How can I fix this and I hope

Thanks

Another way to do this is to < / P>

  db.projects.find ({"US tasks": {$ elemMatch: {"_id": ObjectId ("544029257266e4841735cde8"}}}}) .for each (function (item) For {var us = item.US; (var i = 0; I & lt; Item.US.length; I ++) {var Task = Item. U [i]. Task; (Var i2 = 0; i2 & lt; tasks.length; i2 ++) {var work = work [i2]; Var id = task._id; If (id == "544029257266e4841735cde8") {// new filed task.pointse = {}; break; }}} Db.projects.save (item); });  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -