Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jorgecuesta/mongoose-multitenancy
The best of both worlds Mongoose.discriminator & mongoose-multitenant
https://github.com/jorgecuesta/mongoose-multitenancy
mongoose mongoose-multitenancy mongoose-plugin
Last synced: about 1 month ago
JSON representation
The best of both worlds Mongoose.discriminator & mongoose-multitenant
- Host: GitHub
- URL: https://github.com/jorgecuesta/mongoose-multitenancy
- Owner: jorgecuesta
- License: mit
- Created: 2016-06-06T21:01:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T12:49:27.000Z (almost 2 years ago)
- Last Synced: 2024-04-15T00:25:33.183Z (7 months ago)
- Topics: mongoose, mongoose-multitenancy, mongoose-plugin
- Language: JavaScript
- Homepage:
- Size: 143 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## mongoose-multitenancy
[![Build Status](https://travis-ci.org/jorgecuesta/mongoose-multitenancy.svg?branch=master)](https://travis-ci.org/jorgecuesta/mongoose-multitenancy)
[![Coverage Status](https://coveralls.io/repos/github/jorgecuesta/mongoose-multitenancy/badge.svg?branch=master)](https://coveralls.io/github/jorgecuesta/mongoose-multitenancy?branch=master)
[![npm version](https://badge.fury.io/js/mongoose-multitenancy.svg)](https://badge.fury.io/js/mongoose-multitenancy)
[![Dependency Status](https://david-dm.org/jorgecuesta/mongoose-multitenancy.svg)](https://david-dm.org/jorgecuesta/mongoose-multitenancy)
[![peerDependency Status](https://david-dm.org/jorgecuesta/mongoose-multitenancy/peer-status.svg)](https://david-dm.org/jorgecuesta/mongoose-multitenancy#info=peerDependencies)
[![devDependency Status](https://david-dm.org/jorgecuesta/mongoose-multitenancy/dev-status.svg)](https://david-dm.org/jorgecuesta/mongoose-multitenancy#info=devDependencies)The best of both worlds [Mongoose.discriminator](http://mongoosejs.com/docs/discriminators.html) & [mongoose-multitenant](https://github.com/rosshinkley/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
```javascript
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