JSPM

mongoose-database-service

1.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q34613F
  • License MIT

Promise based database logic for mongoose

Package Exports

  • mongoose-database-service

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mongoose-database-service) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MongooseDatabaseService

Promise wrapped database comms for mongoose

Install

npm install mongoose-database-service --save

API

var db = require('mongoose-database-service')(Model)

where Model is your Mongoose model that you want to CRUD in the database, for example:

var UserModel = mongoose.model('User', userSchema);
var db = require('mongoose-database-service')(UserModel);

Create

db.create( {} )

Passing what you want to save against your model

Update

db.update( {} )

This will merge the existing item with the new data you are passing in

Find, FindOne and FindById

db.find( {queryObject} )
db.findOne( {queryObject} )
db.findById( 'id' )

Pass in an object as query data you want to search on

Remove

db.remove( {queryObject} )

There is plenty more to do

These cover the basics of database CRUD operations, if however you want more feel free to submit a PR