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

MongooseModule: same schema multiple collections #4

Closed
silvelo opened this issue Feb 6, 2018 · 5 comments
Closed

MongooseModule: same schema multiple collections #4

silvelo opened this issue Feb 6, 2018 · 5 comments

Comments

@silvelo
Copy link
Contributor

silvelo commented Feb 6, 2018

I'm submitting a...


[ ] Regression 
[ x] Bug report
[x ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

In Mongo for the same schema
TypeSchema
name: string
_id: ObjectID

is used by multiple collections:
CategoriesCollection
TypesCollection

When you use the mongooseModule, you can define well this collections, but when you inject them on service with @InjectModel(TypeSchema), only one Model is reference.

This is because you inject it with schema as parameters, injectModel as name collections will be better to avoid this.

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Use the same schema for multiple collections.

Environment


Nest version: 4.5.9

 
For Tooling issues:
- Node version: v8.9.4
- Platform:  Windows

Others:

@silvelo
Copy link
Contributor Author

silvelo commented Feb 6, 2018

I was looking in the code, and found the provide is a JSON.stringify of Schema model, for that is you use the same schema even with differents names this problem appear.

I go change the code and make a PR soon with "fix"

@silvelo
Copy link
Contributor Author

silvelo commented Feb 14, 2018

@kamilmysliwiec, Can you check this?

@BorntraegerMarc
Copy link
Contributor

Is there an update on this?

@silvelo
Copy link
Contributor Author

silvelo commented Feb 26, 2018

Only @kamilmysliwiec can do merge, so need wait. Meanwhile I compile with tsc the PR and replace the @nest/mongoose folder to use because in my project I need it.

@kamilmysliwiec
Copy link
Member

Hey, will try to verify this today.

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