The _id =56aea43cb6be380000616b07;
I tried to insert a long string like 56aea43cb6be380000616b07
to the shareids
array in mongodb, it always failed "unexpected token illegal".
I tried this straightforward with the mongo command, it has to be '56aea43cb6be380000616b07' to make it work.
But I checked the type of the _id
with typeof
and it is a string. I tried to set it ObjectID(_id)
but still the same. How could I get this through? Thanks.
collection.update({
"name": name
}, {
$push: {
"shareids":
ObjectID(_id)
}}, function (err) {
if (err) {
console.log("update failed.");
mongodb.close();
return callback(err);
}