2.0.1 • Published 2 years ago

@appveen/swagger-mongoose-crud v2.0.1

Weekly downloads
368
License
MIT
Repository
-
Last release
2 years ago

swagger-mongoose-crud

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

Installation

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

Usage

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 .
2.0.1

2 years ago

2.0.0

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.9

2 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago