Reputation: 3920
Hello every one I'm new to mongodb. While i updating the table i have to get the return values in result
. But it return undefined
,But in the case of find
and insert
the value in table it works properly.
bands.update({name:'Hollywood Rose'}, {$set:{year:2000}}, function(err, result) {
console.log("result----"+result) // it returns undefined
if (!err)
return context.sendJson(result, 404);
})
;
Upvotes: 1
Views: 74
Reputation: 1513
This code work in my case while i update value in the table in mongodb i did this code in playframe work for java . Hope it also help in you case.
MongoClient mongo=new MongoClient("localhost",27017);
/*mongo.setWriteConcern(WriteConcern.JOURNALED);*/
DB db = mongo.getDB("webportal");
DBCollection coll=db.getCollection("userdb");
//ObjectId id= new ObjectId(userid);
BasicDBObject doc2 = new BasicDBObject();
doc2.put("_id",userid);
BasicDBObject updateDocument = new BasicDBObject();
updateDocument .append("$set", new BasicDBObject("username", username1).append("password", password1).append("email", email1));
coll.update(doc2, updateDocument);
Upvotes: 1