What is the “__v” field in Mongoose – remove that field

 const mongoose = require(‘mongoose’);

const userSchema = new mongoose.Schema({
username: {
type: String,
// required: true,
// unique: true
},
email: {
type: String,
// required: true,
// unique: true
},
password: {
type: String,
},
firstname: {
type: String,
},
lastname: {
type: String,
},
address: {
type: String,
},
mobile: {
type: String,
},
age: {
type: Number,
},
gender: {
type: String,
},
userType: {
type: String,
},
versionKey: false //here

},{
versionKey: false //here
});

const User = mongoose.model(‘User’, userSchema);
module.exports = User;

Leave a Comment

Your email address will not be published. Required fields are marked *