Answer the question
In order to leave comments, you need to log in
How to auto increment id for every element in mongoose?
Hello everyone, can anyone tell me how to edit the model for the table in mongoose so that each element would have an id that was auto-incremented when added? Thank you .
This is how I describe the model now:
const { Schema, model } = require("mongoose");
const UserSchema = new Schema({
email: { type: String, unique: true, required: true },
firstName: { type : String, required: true },
lastName: { type : String, required: true },
password: { type: String, required: true },
isActivated: { type: Boolean, default: false },
activationLink: { type: String },
_id: { type: Number }, // ??? Что тут нужно написать ?
});
module.exports = model("User", UserSchema);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question