Answer the question
In order to leave comments, you need to log in
How to correctly connect the mongoose-sequence plugin?
I was not satisfied with the id (they were long, and I just needed the numbering 1,2,3) that mongoose generates and I installed mongoose-sequence
As a result, I successfully applied for the user schema:
const mongoose = require('mongoose')
const AutoIncrement = require('mongoose-sequence')(mongoose);
const UserSchema = new mongoose.Schema({
_id: {
type: Number,
}
},
{ _id: false }
)
UserSchema.plugin(AutoIncrement);
module.exports = mongoose.model("User", UserSchema)
const mongoose = require('mongoose')
const AutoIncrement = require('mongoose-sequence')(mongoose)
const PostSchema = new mongoose.Schema({
_id: {
type: Number,
}
},
{ _id: false }
)
PostSchema.plugin(AutoIncrement);
module.exports = mongoose.model("Post", PostSchema)
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