vamsi reddy
vamsi reddy

Reputation: 143

insert all in database except one in mongodb

i am working on a task where i am workking on create user. i am taking the inputs from the postman and i am validating all the fields and when ever all are validated correctly i am going to insert it in the database.. i am using mongo db as database. But whats the problem is i am taking inputs as first name ,lastname,userid and password and confirm password .. but when i am inserting it the connfirm password also inserting .. so i need to remove that particular field .

   mongo.get().collection("customers").insertOne(req.body, function(err, res) {
    if (err) throw err;
   });

where mongo.get() is the database connection url

Upvotes: 2

Views: 182

Answers (1)

Muhammad Usman
Muhammad Usman

Reputation: 10148

Well you can delete that property from your document/object before inserting into database.

Something like

 delete req.body.confirmPasswordFiled
 mongo.get().collection("customers").insertOne(req.body, function(err, res) {
 if (err) throw err;
 });

Upvotes: 3

Related Questions