Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cc-mongo

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cc-mongo

mongo handler for mongoose models in express framework

  • 0.0.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

cc-mongo

Instaling

npm install --save cc-mongo

How To use

const Mongoose = require('mongoose').Mongoose;
const ModelHandler = require('cc-mongo');
const db = new Mongoose();
db.connect('http://localhost:27017/meteor', { useNewUrlParser: true, useFindAndModify: false }).catch(console.error);

// In our Model Definition
const collectionName = 'user';
const userSchema = new db.Schema({
  _id: { type: String, required: true },
  name: { type: String },
  status: { type: Boolean },
  isRemove: { type: Boolean, default: false },
  createdAt: { type: Date, default: Date.now },
  updatedAt: { type: Date, default: Date.now }
}, {
  collection: collectionName
});

//here we use mongo handler
const User = ModelHandler(db, collectionName, userSchema);

module.exports = User;

Available Methods

MethodsParamsReturn
insertmodel, sessionmodel
updateprops, sessionmodel
remove/hideprops, sessionmodel
delete_id, sessionmodel
insert(model, session):
  • model: the new model to insert into the collection.
  • session | optional: tbd.
update(props, session)
  • props | object:
    • model: the object with new changes.
    • selector | optional: thq condition to the update query. By default: { _id: model._id }.
    • options | optional: to use as option on mongoose updateOne method.
remove(props, session) / hide(props, session) [soft delete]
  • props | object: this method is a direct access to update.
    • model: the object with new changes.
    • selector | optional: thq condition to the update query. By default: { _id: model._id }.
    • options | optional: to use as option on mongoose updateOne method.
  • Before update call, model is manipulated with properties below:
    • updatedAt: new Date()
    • removedAt: new Date()
    • isRemove: true
delete(_id, session) [hard delete]
  • _id: model id to delete

Keywords

FAQs

Package last updated on 17 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc