npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@appveen/swagger-mongoose-crud

v2.0.1

Published

Swagger Mongoose crud wrapper

Downloads

1,951

Readme

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 .