mongodbext-shortid-plugin
v1.0.0
Published
mongodbext shortid plugin
Downloads
2
Readme
mongodbext-shortid-plugin
mongodbext shortid plugin
Plugin parameters
seed
- pass toshortid.seed
characters
- pass toshortid.characters
worker
- pass toshortid.worker
duplicateRetries
- set count of retries to generate unique_id
, default value:5
Example
var MongoClient = require('mongodb').MongoClient,
Collection = require('mongodbext').Collection,
shortid = require('shortid'),
expect = require('expect.js'),
shortidPlugin = require('mongodbext-shortid-plugin');
MongoClient.connect('mongodb://localhost:27017/test', function(err, db) {
var collection = new Collection(db, 'shortidExample');
collection.addPlugin(shortidPlugin);
collection.insertOne({foo: 'bar'}, function(err, doc) {
expect(shortid.isValid(doc._id)).to.be.ok();
});
});