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

mongodb-service

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-service

A mongodb service to perform db operations with promises.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

mongodb-service

A service to perform mongoose queries with promises.

version MIT License XO code style

Note : Populate support will be added soon.

How to use

You can use this module by passing the query, model as params.

Insert

const ms = require('mongodb-service');
const userObj = {
  fname: 'first',
  lname: 'last',
  username: 'testusername',
  email: 'test@gmail.com'
};

ms.create(userObj, TestModel)
      .then(data => {
        //success response
      })
      .catch(err => {
       //handle error
});

findOne

Get one record from the db.

ms.findOne({username: userObj.username}, TestModel)
   .then(data => {
     //handle success
   })
   .catch(err => {
     //handle error
});

Update

Update a record in db. You have to pass query, update query and model for this operation.

ms.update({username: userObj.username}, {$set: {username: 'updatedusername'}}, TestModel)
    .then(data => {
      //handle success
    })
    .catch(err => {
      //handle errror
});

findAll

Get all the documents from db.

 ms.findAll({username: userObj.username}, TestModel)
    .then(data => {
     //handle success
    })
    .catch(err => {
     //handle error
});

Delete

Remove one/all documents.

ms.delete({username: 'updatedusername'}, TestModel)
    .then(data => {
    //handle success
    })
    .catch(err => {
    //handle error
});

Keywords

FAQs

Package last updated on 29 Apr 2018

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