To use delete
you would need to convert the model document into a plain JavaScript object by calling toObject
so that you can freely manipulate it:
user = user.toObject();
delete user.salt;
delete user.pass;
More Related Contents:
- Updating a Nested Array with MongoDB
- How do I update/upsert a document in Mongoose?
- Failed to load c++ bson extension
- Simplest way to wait some asynchronous tasks complete, in Javascript?
- Mongoose find/update subdocument
- Mongoose, Select a specific field with find
- Mongoose difference between .save() and using update()
- Mongoose the Typescript way…?
- Bulk upsert in MongoDB using mongoose
- UnhandledPromiseRejectionWarning: MongooseServerSelectionError
- mongoose .find() method returns object with unwanted properties
- Mongoose subdocuments vs nested schema
- Why is an _id with ObjectID added to when using MongoDB’s $push to add new object to an array?
- Why is my function returning Promise { } [duplicate]
- Mongoose: Find, modify, save
- How to set _id to db document in Mongoose?
- Mongoose.js: Find user by username LIKE value
- How to solve Mongoose v5.11.0 model.find() error: Operation `products.find()` buffering timed out after 10000ms”
- Server Discovery And Monitoring engine is deprecated
- Mongoose Not Creating Indexes
- MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
- MissingSchemaError: Schema hasn’t been registered for model “User”
- Node.js mongodb driver async/await queries
- Find after populate mongoose
- Object.keys() returns unexpected keys on MongoDB object from collection [duplicate]
- What is the difference between id and _id in mongoose?
- JavaScript NoSQL Injection prevention in MongoDB
- Random document from a collection in Mongoose
- Group by Date with Local Time Zone in MongoDB
- MongooseError: Model.findOne() no longer accepts a callback at Function