javascript - Mongoose how to insert element on existing objects (MongoDB and Node.js) -
in model, have this:
subjects: { mathematics: { questionsanswered: [ "x+2=3, solve x please", "how write expression represents quadrantal angles?" ], questionsasked: [ "how convert sin cos?", "factor trinomial: 3x^2+7x+2" ] } } as can see, there're lot of sub-elements , i'm totally beginner mongoose , node.js, i'm trying add question(string) in questionsanswered array field. looked on documentation , tried
usermodel.update({username: username},{$pushall: { subjects:{mathematics:{questionsasked:['what definition of calculus']}}}},{upsert:true},function(err){ if(err){ console.debug(err); }else{ console.debug("successfully added"); } }); but says 'modifier $pushall allowed arrays only', know how insert element in questionsanswered array? lot ahead!
Comments
Post a Comment