Need Paper Mache

    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

    24

    Version

    1.0.3

    License

    MIT

    Last publish

    Collaborators

    • neogeek