-
Notifications
You must be signed in to change notification settings - Fork 137
Allow refType to be defined in @prop (issue #146) #149
Conversation
restrict PropOptions.refType to number, string, Buffer and ObjectID
As an additional note, I was really hoping to figure out a way to just define the refType by doing @prop({ ref: Car })
car?: Ref<Car, number>; but I'm not familiar enough with reflect-metadata to know what the process might be. I ran into microsoft/TypeScript#9916 which suggests this might not be possible. |
ba00e85
to
f446b14
Compare
b8b5930
to
191bb6b
Compare
any news? |
@mattjennings, when you still work with typegoose / willing todo so, would you resolve the merge conflicts, and try to get news on this? could someone say to me why someone would do EDIT: i think i now know what it means |
Sorry, I haven't used typegoose in over a year (since making the PR), so I'm afraid I'm not familiar enough anymore to address the conflicts. @hasezoey I think you're right that it meant |
Hi! Merged, solved conflicts and added tests here (also added itemsRefType): https://github.com/mfulop/typegoose Should I post a separate pull request from that repo? |
@mfulop yes, please open a new pr if you have a diffrent repo than here |
Sure, will do. AFK for a hour or two |
I think I did :) please see #369 |
@mfulop you dont need to mention it, i am subscribed to the whole project :) |
I know I am just not sure the rebase went well |
Improving on #148, I restricted the PropOptions.refType to be a union type of strings 'number', 'string', 'Buffer', and 'ObjectID'.
I previously was doing a union type of
however when mongoose.Schema.Types.Buffer is part of the union type then Typescript seemed to allow any of the mongoose.Schema.Types
Ref has also been modified a bit to cast the correct refType.
A prop example of how it can be used: