I have in a collection documents like the following:
{
id: ObjectId(13796844978),
n_empleado:1,
geometry:{
coordinates:[0,1]
}
}
I'm trying to update the coordinates array and I can't find a way. I am trying, for example, with the following query to add the value 8 to the array:
db.collection.update({n_empleado:1},{$push:{geometry.coordinates:8}})
But an error pops up. The error that the Mongo console gives me is:
E QUERY [thread1] SyntaxError: missing : after property id @(shell):1:50
I'm also looking for a way to replace the array with another:
db.collection.update({n_empleado:1},{$set:{geometry.coordinates:[4,5]}})
and it also gives an error. The error in this case is:
E QUERY [thread1] SyntaxError: missing : after property id @(shell):1:49
Any ideas how I can get it?
Since your query includes nested documents, you must use quotes to reference them correctly.
Thus, instead of saying:
You must say:
Reference: query in mongo Shell gives SyntaxError: missing : after property