You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
The getModelForClass() function takes a GetModelForClassOptions argument, but this argument is never used in the cache mechanism.
Hence, if you call getModelForClass with different options, the cache will not notice it and the returned Model won't be the one expected.
I guess it doesn't much make sense to create two different Model from the same class. I suggest that the GetModelForClassOptions should be placed somewhere else.
The ideal thing for me would be something like this :
@modelOptions({existingMongoose: /* ... */,existingConnection: /* ... */,schemaOptions: /* ... */,})exportclassEntityextendsTypegoose{/* ... */}exportconstModel=newEntity().getModelForClass(Entity);//No more option allowed here
This way, you cannot use differents options anymore on the same class and you can use getModelForClass() multiple times without fear.
The alternative would be to use the options as keys in the cache. But it seems useless from my point of view.
What do you think ? I'm willing to write a PR if this makes sense to everyone.
The text was updated successfully, but these errors were encountered:
- removes modeloptions from all functions
- adding @modeloptions for Classes
- adding test for @modeloptions
- set tslint rule "max-line-length" to warn instead of erroring
fixes szokodiakos#186
fixes hasezoey#6
The
getModelForClass()
function takes aGetModelForClassOptions
argument, but this argument is never used in the cache mechanism.Hence, if you call
getModelForClass
with different options, the cache will not notice it and the returned Model won't be the one expected.I guess it doesn't much make sense to create two different Model from the same class. I suggest that the
GetModelForClassOptions
should be placed somewhere else.The ideal thing for me would be something like this :
This way, you cannot use differents options anymore on the same class and you can use
getModelForClass()
multiple times without fear.The alternative would be to use the options as keys in the cache. But it seems useless from my point of view.
What do you think ? I'm willing to write a PR if this makes sense to everyone.
The text was updated successfully, but these errors were encountered: