javascript - Mongo/Mongoose - markModified not working -
i have following query:
section.find({"clause": sub.section}, function(err, docs){ var detail = parseint(sub.detail); docs[0].subclauses[0].additionaldetails[detail-1].percentile = sub.percentile; docs[0].markmodified("subclauses"); docs[0].save(function(err, doc){ if(err) { return callback(err) }; callback(); }) }) when log doc inside .save function appears have saved successfully. on querying db elsewhere save has not happened. object trying save 3 deep this:
[ { "clause": "1", "subclauses: [ { "clause":"1.1", "additionaldetails: [ { "detail": "1", "content": "whatever" } ] } ] } ] with several items inside each array.
am not able save data nested array object using mongo?
if understand trying do, think wanting use mongo position operator ($). used index nested arrays in document. in current code referencing first object in array. using position operator able reference other positions based of other data, such query.
here documentation operator: http://docs.mongodb.org/manual/reference/operator/update/positional/
and here stack overflow response may bit also: mongodb $ operator
Comments
Post a Comment