mongo-increment

1.0.1 • Public • Published

mongo-increment

Increment util for mongoose.

Install

$ npm i mongo-increment -S

Usage

const mongoose = require('mongoose');
const mongoIncrement = require('mongo-increment')(mongoose);
 
mongoose.connect(process.env.MONGODB_URL, {
  useUnifiedTopology: true,
  useNewUrlParser: true,
  useCreateIndex: true,
  useFindAndModify: false,
});
 
const Users = mongoose.model('users', new mongoose.Schema({
  _id: Number,
  firstName: String,
  lastName: String,
}, { _id: false }));
 
const Reviews = mongoose.model('reviews', new mongoose.Schema({
  _id: Number,
  text: String,
  starts: Number,
}, { _id: false }));
 
mongoIncrement(Users, Reviews, ...); // => Promise
 
module.exports = {
  Users,
  Reviews,
};

Readme

Keywords

none

Package Sidebar

Install

npm i mongo-increment

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

3.56 kB

Total Files

4

Last publish

Collaborators

  • bifot