Skip to content

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

License

Notifications You must be signed in to change notification settings

jorgecuesta/mongoose-multitenancy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published