0.0.4 • Published 6 years ago

@alakermi/mongooseuuid v0.0.4

Weekly downloads
17
License
MIT
Repository
github
Last release
6 years ago

Build Status Coverage Status

generate random unique uuid for Mongoose schema

Prerequisites

  • npm >=5.5.0

Install

To use mongooseuuid for an existing mongoose schema you'll have to require and plugin mongooseuuid into the existing schema.

$ npm install @alakermi/mongooseuuid --save

Usage

import mongoose from 'mongoose';
import mongooseuuid from 'mongooseuuid';
 
mongoose.connect('mongodb://localhost/Default');
 
// Default options
let options = {
  field:"myid" // default options 'uniqueid'
};
 
// Add the plugin to the schema with default options
let Schema = mongoose.Schema({ myid: 'string', });
Schema.plugin(mongooseuuid(options));
 
// Create a model
let Guest = mongoose.model('guest', Schema);
 
// Create and and save document
let guest = new Guest({})
await guest.save()

Options

  • field: name of the field to affec uuid for it . The default is 'uniqueid'. this options is required or it will throw an error

Author

šŸ‘¤ Abdelhak Akermi

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ā­ļø if this project helped you!


0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago