Neverending Prototype Mode
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

mongoose-create-or-update

1.0.3 • Public • Published

mongoose-create-or-update

A Promise-based Mongoose plugin for creating and updating documents in a single statement.

Build Status codecov NPM Version Greenkeeper badge Latest Documentation

Install

$ npm install mongoose mongoose-create-or-update --save

Usage

const mongoose = require('mongoose');
 
const dataSchema = new mongoose.Schema({
    'contents': String
});
 
dataSchema.plugin(require('mongoose-create-or-update'));
 
const dataModel = mongoose.model('data', dataSchema);
let dataId = null;
 
dataModel.createOrUpdate({
    '_id': dataId
}, {
    'contents': 'Lorem ipsum dolor sit amet'
}).then(data => {
 
    dataId = data._id;
 
    done();
 
}).catch(err => {
 
    console.log(err);
 
});

Documentation

View full documentation here.

install

npm i mongoose-create-or-update

Downloadsweekly downloads

21

version

1.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability