jorgecuesta / mongoose-multitenancy

The best of both worlds Mongoose.discriminator & mongoose-multitenant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mongoose-multitenancy

Build Status Coverage Status npm version Dependency Status peerDependency Status devDependency Status

The best of both worlds Mongoose.discriminator & mongoose-multitenant This package uses the mongoose discriminator functionality to extend schemas and uses the logic of mongoose-multitenant to create the models. Right now multitenancy just works with collections.

Installation

npm install mongoose-multitenancy

@NOTE: It requires mongoose as peerDependency.

Usage

var mongoose = require('mongoose');

// It automatically adds logic to mongoose.

var multitenancy = require('mongoose-multitenancy');

multitenancy.setup();

var LogSchema = new mongoose.Schema({
    entry: {
        type: String,
        required: true
    },
    user: {
        type: new mongoose.Schema({
            username: {
                type: String,
                required: true
            }
        })
    }
});

mongoose.mtModel('Log', LogSchema);

Tests

npm test

About

The best of both worlds Mongoose.discriminator & mongoose-multitenant

License:MIT License


Languages

Language:JavaScript 100.0%