How to Use MongoDb Nativ Query With Model in NodeJS | node-js-tutorial.blogspot.com
In this artical, you have learn how to use mongo native query with node model.
let understand some code.
Following code use for conver Sting To Object ID.
Declare in top of Your code.
Nativ query Understand Object Id not String.
Here Query is for push Record in Array.
Thanks.
In this artical, you have learn how to use mongo native query with node model.
let understand some code.
Following code use for conver Sting To Object ID.
Declare in top of Your code.
var ObjectId = require('mongodb').ObjectID;
Nativ query Understand Object Id not String.
let userId = '123232323232'; // ID of User.
Your_Model.native(function (err, modelObj) {
modelObj.update({ "_id": new ObjectId(userId) },
{ $push: { <feild>: { <feild>: <value> } } },
function (err, res) {
if (err) {
// Print Error Log
console.log(err);
} else {
// Print Success Log
console.log(res.result);
}
});
}); // End Nativ
Here Query is for push Record in Array.
Thanks.
good code. thanks very helpful for me.
ReplyDeleteit Solve my big issue.
Thanks for posting such a informative content by your blog. keep sharing more post.
ReplyDeleteNode JS Training
Node JS Online Training
Best article, very useful and explanation. Your post is extremely incredible. Thank you very much for the new information.
ReplyDeleteNode Js Online Training in Hyderabad
Best Node Js Online Training in Hyderabad
Node Js Training
Node Js Online Training in Ameerpet
Good post and informative. Thank you very much for sharing this good article, it was so good to read and useful to improve my knowledge as updated, keep blogging.
ReplyDeleteNode JS Online training
Node JS training in Hyderabad
wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This is good information and really helpful for the people who need information about this. I have learned a lot from this
ReplyDeleteoracle training in chennai
oracle training institute in chennai
oracle training in bangalore
oracle training in hyderabad
oracle training
oracle online training
hadoop training in chennai
hadoop training in bangalore