how to create auto increment id in mongoose code example

Example: auto increment in mongoose + nodejs

...
var bookSchema = new Schema({
    author: { type: Schema.Types.ObjectId, ref: 'Author' },
    title: String,
    genre: String,
    publishDate: Date
});

bookSchema.plugin(autoIncrement.plugin, 'Book');
var Book = connection.model('Book', bookSchema);
````

That's it. Now you can create book entities at will and they will have an `_id` field added of type `Number` and will automatically
 increment with each new document. Even declaring references is easy, just remember to change the reference property's type
 to `Number` instead of `ObjectId` if the referenced model is also using the plugin.

````js
var authorSchema = new mongoose.Schema({
...