Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.92 KB

README.md

File metadata and controls

51 lines (37 loc) · 1.92 KB

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