Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Plugin Multiple Times Per Schema #44

Open
amerryma opened this issue Jan 29, 2019 · 3 comments
Open

Use Plugin Multiple Times Per Schema #44

amerryma opened this issue Jan 29, 2019 · 3 comments
Milestone

Comments

@amerryma
Copy link

Hi, I've been using this plugin for a long time now but I have an interesting use-case that I'm trying to solve without actually forking this library. Basically, we already use the plugin to add a tenantId to every mongoose model in our application, but we want to take it one step further. I wanted to add another field to the same model where I could chain the accessorMethod's and continue to narrow down the search. For example:

User

{
   name: "Aaron",
   tenantId: "A",
   tenantId2: "1"
}
{
   name: "Alrik",
   tenantId: "A",
   tenantId2: "2"
}
{
   name: "Someone",
   tenantId: "B",
   tenantId2: "2"
}

Basically as it stands right now I have to use User.byTenant("A") to get the model that I need for querying. But what I'd like to be able to do is something like User.byTenant("A").byTenant2("1") which would just return the Aaron user. I know it's not a typical use-case but just wondered if there would be an easy way to implement this. Otherwise if I end up forking it, do you have any recommendations?

@alrik
Copy link
Member

alrik commented Jan 30, 2019

@amerryma so you are looking for a compound tenant id, did i understand you right?

@amerryma
Copy link
Author

amerryma commented Jan 31, 2019

@alrik Yes, that appears to be what I'm looking for. Any thoughts?

@baranga
Copy link
Contributor

baranga commented Mar 21, 2019

@amerryma So your schema has two or more fields referencing different entities from the same collection? Or do the fields reference different collections? (multiple values from the same dimension or multiple values from a different dimension each?)

Maybe you can explain your use case a bit more in depth to make it a bit clearer what you want to achieve.

@baranga baranga added this to the 2.0.0 milestone Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants