Skip to content

Mongoose plugin that auto-increments any ID field on your schema every time a document is saved.

License

Notifications You must be signed in to change notification settings

Avila-Tek/mongoose-auto-increment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongoose Auto Increment

This repo is based of chevtek/mongoose-auto-increment we take the code update it!

The usage is as simple as this:

import mongoose from 'mongoose';
import { plugin, initialize } from 'avilatek-mongoose-autoincrement';

initialize(mongoose.createConnection('mongodb://localhost/myDatabase'));

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

bookSchema.plugin(plugin, 'Book');
const Book = mongoose.model('Book', bookSchema);

Docs

Under construction

Credits

  • TSDX
  • mongoose-auto-increment

Author

About

Mongoose plugin that auto-increments any ID field on your schema every time a document is saved.

Resources

License

Stars

Watchers

Forks

Packages

No packages published