@ladjs/mongoose
Mongoose helper for Lad
Last updated 11 days ago by niftylettuce .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @ladjs/mongoose 
SYNC missed versions from official npm registry.

@ladjs/mongoose

build status code coverage code style styled with prettier made with lass license

Mongoose helper for Lad

Table of Contents

Install

npm:

npm install @ladjs/mongoose mongoose

yarn:

yarn add @ladjs/mongoose mongoose

Requires mongoose v5 to be a dependency in your project.

Usage

This package is a mongoose connection helper that sets up some sensible default connection options for mongoose and event dubugging helpers.

The default options are outlined below.

This package also provides reconnection logic on the initial connection. This is especcially convenient as this is not baked into mongo or mongoose natively. Mongoose will, however, take over reconnection in the event there is a disconnect event.

Usage:

const Mongoose = require('@ladjs/mongoose');
const mongoose = new Mongoose({
  // ...
});
mongoose
  .connect()
  .then()
  .catch(console.error);

Now require and use the mongoose singleton in the rest of your project as you normally would.

const mongoose = require('mongoose');

Options

Option Type Default Description
mongo Object configuration object configuration object
mongo.options Object reconnectTries: Number.MAX_VALUE
reconnectInterval: 1000
useNewUrlParser: true
any valid mongoose configuration object
which is passed to mongoose.connect()
see mongoose options docs
debug Boolean false set with mongoose.set
useCreateIndex Boolean true set with mongoose.set
bufferCommands Boolean undefined set with mongoose.set
useFindAndModify Boolean undefined set with mongoose.set
useNewUrlParser Boolean undefined set with mongoose.set
cloneSchemas Boolean undefined set with mongoose.set
applyPluginsToDiscriminators Boolean undefined set with mongoose.set
applyPluginsToChildSchemas Boolean undefined set with mongoose.set
objectIdGetter Boolean undefined set with mongoose.set
runValidators Boolean undefined set with mongoose.set
toObject Boolean undefined set with mongoose.set
toJSON Boolean undefined set with mongoose.set
strict Boolean undefined set with mongoose.set
selectPopulatedPaths Boolean undefined set with mongoose.set
maxTimeMS Boolean undefined set with mongoose.set
autoIndex Boolean undefined set with mongoose.set

A note on useUnifiedTopology

In mongoose 5.7 the mongo driver version was bumped which caused some deprecation warnings when using the option useUnifiedTopology with the options recconectTries and reconnectInterval. @ladjs/mongoose uses both of these options internally for initial connection retries if needed. However, we detect version under the hood and omit all problematic options automatically from the connection if needed. We encourage users to continue setting these options even if they are using the new unified topology.

Contributors

Name Website
Nick Baugh http://niftylettuce.com
Spencer Snyder http://spencersnyder.io

License

MIT © Nick Baugh

Current Tags

  • 2.1.1                                ...           latest (11 days ago)

16 Versions

  • 2.1.1                                ...           11 days ago
  • 2.1.0                                ...           12 days ago
  • 2.0.2                                ...           14 days ago
  • 2.0.1                                ...           9 months ago
  • 1.0.1                                ...           9 months ago
  • 1.0.0                                ...           9 months ago
  • 0.1.5                                ...           9 months ago
  • 0.1.4                                ...           9 months ago
  • 0.1.3                                ...           9 months ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 43
Last Month 63
Dependencies (4)
Dev Dependencies (15)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |