Hi @hasezoey , thanks for maintaining this project
I just refactored a project to use Typegoose instead of just Mongoose. I'm using the 6.0 "next" version on NPM. But when I start my server, I get this error:
Error: "undefined.users"'s Type is invalid! Type is: "undefined"
The error is quite vague, and it's hard to know where it comes from, especially since I just made a lot of changes. All I know is that users is one of my collections.
Is it introspecting my database to see if it matches the generated schema ? Did I mess up a prop() ?
Thanks
The error is quite vague,
i actually tried to make the errors as "not vague" as possible, it is in the format of "Class.Property"
so it means:
for more help i would need the model it errors on, and sorry for the wrong stacktrace, this is because of DEO (#23,#24)
Thanks for the quick response.
I thought it was a problem with my User model, but since the users in the error message is a property, I found that it comes from another model (Brand) that has a users property. It's a reference to the User model.
Here's how it's defined:
class Brand {
// Other props above
@arrayProp({ itemsRef: User })
users: Ref<User>[]
}
const BrandModel = getModelForClass(Brand)
where User is a class with @prop attributes from another file.
Removing the users attribute from the Brand gets rid of the error, but how can I actually fix this ?
could you do a minimal repo script?
Update: try to update to 6.0.0-30, this should fix the "undefined.users" verify that it is "Brand"
Another Update: could you try setting itemsRef: User to itemsRef: "User"?
-> when this solved it, please read here on why it is so
You nailed it:
Thanks for the help!
Unrelated: I noticed the repo changed ownership, so you should change the link to the Github pages site in the repo's description
Unrelated: I noticed the repo changed ownership, so you should change the link to the Github pages site in the repo's description
i will, once i release version 6.0.0, for now github just redirects to here :)
so, this issue is solved now? when yes you can close this
This issue is back at 7.0.0
@ChrisLahaye please open a new issue with reproduction code
Most helpful comment
could you do a minimal repo script?
Update: try to update to 6.0.0-30, this should fix the "undefined.users" verify that it is "Brand"
Another Update: could you try setting
itemsRef: UsertoitemsRef: "User"?-> when this solved it, please read here on why it is so