Pushing array elements from android app to a mongoose schema

10 views
Skip to first unread message

ZR

unread,
Jun 22, 2015, 6:57:46 AM6/22/15
to mongoo...@googlegroups.com


Hi All,

I am trying to figure out how to push array elements from my android app to a mongoose schema.

My schema looks like this:

var userSchema = mongoose.Schema({
   var1 : String,
   var2: String,
   myArray:   [String]
});

When I try to populate the array using:

user.findByIdAndUpdate(id,{$push: {myArray: {$each: [myArray]}}}, function (err, user) {
 if (err) return handleError(err);
callback({'response':"Success"});
});

I get the following error:

user.findByIdAndUpdate(id,{$push: {myArray: {$each: [myArray]}}}, function (
                                                      ^
ReferenceError: myArray is not defined

Is there anyone who could help with this?
Thanks a lot.
Reply all
Reply to author
Forward
0 new messages