npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sails-hook-mongoose

v0.0.2

Published

Sails hook for mongoose

Downloads

2

Readme

Sails hook mongoose

Version 0.0.1

Getting started

npm install sails-hook-mongoose

Usage

Configuration

module.exports.globals = {
    mongoose: true,  // Expose mongoose as a global variable
    ObjectId: true,  // Expose ObjectId as a global variable
    Mixed: true      // Expose Mixed as a global variable
};

module.exports.mongoose = {
    plugins: { ... }, // plugins for all your schemas in all connections (optional)

    schemasLocation: "./api/schemas", // base schemas location path

    connection: { ... }, // alias for connections.default

    connections: {
        default: { ... },     // Default connection. Schemas will be exposed as a global variable by default.
        connection2: { ...  } // You can configure others connections
    }
};


connections.foo_connection = {
    uri: "localhost",
    options: {
        database: "dbname",
        port: 12345,
        user: 'user',
        pass: 'pass',
        ...
        [ other mongoose options ]
    },
    wrap: false, // Wrap schemas, optional.
                 // false for the default connection.
                 // Others connections use the connection name (in this example: 'foo_connection')
                 // Multiple connections could have this value to false, but be careful with name collisions
    schemasLocation: "./api/schemas/foo" // optional, defaults to mongoose.schemasLocation + connection_name
    plugins: { ... }
}

// Plugin parameter could be a string array or a object
// Scheme plugins override connection plugins, connection plugins override general plugins
plugins = ['mongoose_plugin_to_require', 'mongoose_plugin_to_require_2']; // load all plugins with no params

plugins = {
    'mongoose_plugin_to_require': true, // load 'mongoose_plugin_to_require' with no params

    'mongoose_plugin_to_require_2': {...}, // load the plugin with the given params

    'do_what_ever_you_want': function(schema) { // Do what ever you want with the schema
        ...
    }
};

Schemas definitions

module.exports = {
    attributes: { // Mongoose schema
        ...
    },

    statics: {  // Scheme statics
        ...
    },

    methods: {  // Scheme methods
        ...
    },

    plugins: {
        ...
    }
}

Examples

https://github.com/highfredo/sails-hook-mongoose/tree/master/examples


TODO:

  • add examples.
  • add test.
  • clean up the code.
  • improve readme.