I am facing a challenge with my Mongo DB structure, which is structured as follows:
db.users.find().pretty();
{
"_id" : ObjectId("52b42b148ffa91f7ebbe8ebc"),
"username" : "test",
"password" : "test",
"party" : [
"4988",
"5037"
],
"something" : [
"3571"
],
"ludilo" : [],
}
In my application built on express js, I use this module to connect to Mongo https://npmjs.org/package/mongodb.
My question is how can I add a new entry into the "something" array for a user based on the session id.
I attempted the following code snippet, but unfortunately it did not work as expected
var collection = db.collection('users');
collection.find({'_id':new ObjectID(req.user.id)}).toArray(function(err, items) {
console.dir(items);
}).insert({"something":"1234"});