Given the following schema
{
"_id" : ObjectId("55e0ecfa422d86f0a3b37b90"),
"username" : "Michael",
"hostedEvents" : [
{ "_id" : "1", "usersApplied" : [ ] }
],
"joinedEvents" : [
{ "confirmed" : false }
]
}
And I am trying to push into the usersApplied array the string "Lisa"
Right now I have a mongodb command that works but I want to do this in mongoose:
db.users.update({username:'Michael', "hostedEvents._id": "1"},
{$addToSet: {"hostedEvents.$.usersApplied": {"username":"Lisa"}}});
I tried to do it in mongoose this way:
Users.update({username:'Michael', "hostedEvents._id": "1"},
{$addToSet: {"hostedEvents.$.usersApplied": {"username":"Lisa"}}});
I am trying to follow the recommendation made here