Hello I am new to MongoDB and i have been looking for a way to add a field to a embedded document in an array
// collection
> db.test.find().pretty();
{
"_id" : ObjectId("5761765a31356152793c8790"),
"name" : "bb",
"email" : "bb@mail",
"projects" : [
{
"project_id" : ObjectId("576179bf31356152793c879c")
//How can i add a name here
}
]
}
>
$set: {"projects.0.name": "foo"}?db.test.update({name:'bb'},{$set :{projects.0.name:'foo'}})and it gives me this error SyntaxError: Unexpected number