1.2.9 • Public • Published


    Build Status

    A Simple wrapper for Swagger based mongoose CRUD operation. This plugin is a modfied version of the Mongoose CRUD operation introducted by Micheal Krone.

    This module exposes following basic operations.

    • Create
    • Update
    • Read
    • Delete
    • Index (list)
    • Count
    • bulkUpdate
    • bulkUpload
    • bulkShow
    • markAsDeleted
    • rucc


    npm install @appveen/swagger-mongoose-crud --save


    var Mongoose = require('Mongoose');
    var SMCrud = require('swagger-mongoose-crud');
    //In your controller, simply expose the following
    var schema = new Mongoose.Schema({ 
        //Your mongoose Schema definition here.
    var modelName = "Your model Name";
    var options = {
     collectionName: "name of your collection",
     logger: "your logger object",
     defaultFilter: "default filter object for all read operations",
     permanentDeleteData: "To be set true, when soft delete is disabled"
    var crud = new SMCrud(schema,modelName, options);
    var exports = {};
    //Takes all parameters for creating an entry
    exports.create = crud.create; 
    //Takes parameter 'id' for searching in the DB, will update rest of the parameters.
    exports.update = crud.update;
    //Will list out the entire collection, No parameters
    exports.index = crud.index;
    //Will mark the entity as deleted by setting deleted flag to true, takes 'id'
    exports.markAsDeleted = crud.markAsDeleted;
    //Will delete the entity, takes 'id'
    exports.destroy = crud.destroy;
    //Will show a single entity, takes 'id'
    exports.show = crud.show;
    //Will count the number of entries in the DB, Supports filter options.
    exports.count = crud.count;
    //Will update multiple document, takes comma separated 'id'
    exports.bulkUpdate = crud.bulkUpdate;
    //Will create multiple documents, takes file with comma separated data
    exports.bulkUpload = crud.bulkUpload;
    //Will show multiple entity, takes comma separated 'id'
    exports.bulkShow = crud.bulkShow;
    // Will ensure consistency when there are multiple parallel updates expected on the same document. This module is partially incomplete.
    exports.rucc = crud.rucc; 
    //crud.model will hold the Mongoose Model.
    //crud.schema will hold the schema passed on at constructor
    crud.select = [ 
        //list of the fields for the listing in Index call
    crud.omit = [
        //list of the fields to disallow for Index search
    module.exports = exports;

    Fields added by this library to your schema

    • createdAt : Type Date. The time of creation of the document
    • lastUpdated : Type Date. The last updated time of the document
    • deleted : Type Boolean. This is false by default. The

    Indexed fields

    • lastUpdated
    • createdAt .


    npm i @appveen/swagger-mongoose-crud

    DownloadsWeekly Downloads






    Unpacked Size

    55.4 kB

    Total Files


    Last publish


    • appveen