I am creating an API to get and post values from a Database using the MEAN stack.
I want to automatically generate the userID starting from 0 when each entry is created in the usesrschema.
var userSchema = new mongoose.Schema({
//userId: Number,
username: String,
password: String, //hash created from password
created_at: {type: Date, default: Date.now}
})
How is it that I add a userID starting from 0 and autoincrementing with each insertion?