Comments (2)
I have this in my system but have dealt with it in a different way.
I have a teams
model which has many users
, A team
can represent an (github) organisation, or a project, etc. and a team
belongs to a single mongo-tenant
, while the users
model doesn't have a mongo-tenant
plugin.
So you can get the users:teams[]
and users:currentTeam
and retrieve mongoose models based on the current team
the user is viewing.
A user
may belong to many teams
, so you can fetch the team
model and retrieve all the users
that belong to the team; or you can select a user
and retrieve all the teams
they belong to.
This can become very difficult to deal with, and every system may have to handle with it in very specific ways, especially when you start to consider different access rights according to tenants
, or billing and subscriptions based on teams
.
Perhaps you should consider thinking about another way of handling this instead of changing this mongo-tenant
package to suit your requirements? As everyone else who uses this package may have different needs and it might be better to keep it as simple as possible, or create a clone and modify it for what you need.
And how will it impact performance if you have to search through arrays of multiple tenants for each query?
Just a suggestion... I'm not against any changes, I'm just saying it can become complicated very quickly and it might be better to deal with that logic on another level.
from node-mongo-tenant.
@tao make sense, thanks for hints!
from node-mongo-tenant.
Related Issues (20)
- Add release notes
- Run tests against node LTS versions HOT 1
- Force TenantId to be Required HOT 3
- Using the custom config "tenantIdKey" for create HOT 2
- Ensure Mongoose 5 compatibility
- Problem with discriminator key HOT 1
- mongoose 'deleteOne' function is still able to delete across tenants HOT 2
- Use Plugin Multiple Times Per Schema HOT 3
- Schema.countDocuments returns total count of elements ignoring tenantId HOT 3
- Add multi-tenant support to complete mongoose model api
- Collection-level multi-tenancy HOT 2
- How to use database level ? HOT 1
- Add Typescript Support HOT 6
- How to implement node-mongo-tenant with node-restful? Newbie Question
- Add immutable option to make the tenantId field immutable HOT 1
- Multitenant model does not override updateMany. HOT 2
- Error when use `Model.aggregate`: Mongoose 5.x disallows passing a spread of operators to `Model.aggregate()`. Instead of `Model.aggregate({ $match }, { $skip })`, do `Model.aggregate([{ $match }, { $skip }])` HOT 1
- preserveUniqueKey flag not working properly
- Flag to disable injection on create
- support array of tenant ids to getTenant HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-mongo-tenant.