Notorious Public Menace

    @ladjs/mongoose

    4.0.2 • Public • Published

    @ladjs/mongoose

    build status code style styled with prettier made with lass license

    Mongoose helper for Lad

    Table of Contents

    Install

    npm:

    npm install @ladjs/mongoose mongoose

    Requires mongoose v6 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({
      // ...
    });
    
    (async () => {
      await mongoose.connect();
    })();

    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 {} mongoose connection options
    which are passed to mongo
    see mongo options docs
    reconnectTries Number Number.MAX_VALUE How many times @ladjs/mongoose will attempt to create the initial connection
    reconnectInterval Number 1000 Time in ms between initial connection attempts
    hideMeta String or false Boolean "hide_meta" Appends a true boolean property to a property with this value in logs, e.g. console.log('mongoose disconnected', { hide_meta: true }); which is useful for preventing metadata object from being invoked as the second argument (this is meant for usage with [Cabin][] and [Axe][] and made for [Forward Email][forward-email]). If you pass a false value then this property will not get populated.
    --- --- --- ---
    applyPluginsToChildSchemas Boolean undefined set with mongoose.set
    applyPluginsToDiscriminators Boolean undefined set with mongoose.set
    autoCreate Boolean undefined set with mongoose.set
    autoIndex Boolean undefined set with mongoose.set
    debug false undefined set with mongoose.set
    returnOriginal Boolean undefined set with mongoose.set
    bufferCommands Boolean undefined set with mongoose.set
    cloneSchemas Boolean undefined set with mongoose.set
    timestamps.createdAt.immutable Boolean undefined set with mongoose.set
    maxTimeMS Boolean undefined set with mongoose.set
    objectIdGetter Boolean undefined set with mongoose.set
    overwriteModels Boolean undefined set with mongoose.set
    returnOriginal Boolean undefined set with mongoose.set
    runValidators Boolean undefined set with mongoose.set
    sanitizeFilter Boolean undefined set with mongoose.set
    selectPopulatedPaths Boolean undefined set with mongoose.set
    strict true undefined set with mongoose.set
    strictQuery false undefined set with mongoose.set
    toJSON Boolean undefined set with mongoose.set
    toObject Boolean undefined set with mongoose.set

    Contributors

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

    License

    MIT © Nick Baugh

    Install

    npm i @ladjs/mongoose

    DownloadsWeekly Downloads

    153

    Version

    4.0.2

    License

    MIT

    Unpacked Size

    23.6 kB

    Total Files

    4

    Last publish

    Collaborators

    • titanism
    • shadowgate15
    • niftylettuce
    • shaunwarman
    • spence-s