2012.1.0 • Published 13 years ago
mongoose-pureautoinc v2012.1.0
mongoose-pureautoinc
This plugin let you add an auto increment field to your schema.
Requirements
- Node.js, a server-side JavaScript implementation,
- MongoDB, a NoSQL database,
- Mongoose, an elegant Object Document Mapper for MongoDB.
Installation
Install it from NPM as you always do it with other packages.
npm install mongoose-pureautoincAvailable options
model- required parameter, name of your Mongoose modelfield- name of your fieldstart- first value of your field which will be used
How to use
You can run example using this command:
$ node examples/example.jsFirstly, you need to require Mongoose and the plugin.
var mongoose = require('../node_modules/mongoose'),
Schema = mongoose.Schema,
db = mongoose.createConnection('127.0.0.1', 'yourDatabaseName'),
pureautoinc = require('pureautoinc');Secondly, you need to initialize the plugin, define your schema and connect the plugin to it.
pureautoinc.init(db);
var schema = new Schema({
email: String,
text: String
});
schema.plugin(pureautoinc, {
model: 'Subscriber',
field: 'recordNum'
});After that you can create your model and use it as you wish.
var Subscriber = db.model('Subscriber', schema);For developers
You should use Git pre-hook to validate your changes. Just copy pre-commit file into ./git/hooks/ directory.
In order to run tests manually execute $ vows --spec tests/*
In order to test performance of the plugin execute $ node benchmarks/benchmark.js
Copyright
© 2012 MyLove Company, LLC. Source code is distributed under CDDL 1.0 open source license.
2012.1.0
13 years ago