-
Notifications
You must be signed in to change notification settings - Fork 69
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
Id as a generic type parameter #42
Comments
Thnaks for the suggestioin. Can you tell me about what you want to use for Id and why? |
I use In any case, I might want to change that behavior for my next project to use other data type, say |
@Rm2k when we're using mongodb as a store, |
@SorenZ sorry if i put it to you that
And my issue is, the library is being harsh to poor minds like me, who would like to do something like this: Thats why i say why not make it generic like its done in |
@Rm2k no no, I didn't think so :) |
@SorenZ thanks for the clarification. |
I just thought how to implement it (in best way) and eagerly waiting to hear from @tugberkugurlu ... |
@Rm2k This could be a valid feature request to add, especially for migration cases. However, I still believe MongoDB Id should be the suggested way. So, even if we get this in, we should not make the users choose an id type. @SorenZ can you elaborate what approach you are thinking about? You can PR it if it's easier than explaining 😄 |
PR is really easier than explaining (for me) :))) |
@SorenZ cool, looking forward to it! |
@tugberkugurlu @SorenZ I think the solution to this problem is fairly straightforward as in MongoDB _id field can be of any type i.e. ObjectId (default), String, Int, or a JSON Object. So, to fix this problem what needs to be done is when creating Document from the class the _id should be set to the value of the same type as Id field i.e. Suppose Class have |
I want to clarify something that even if you work with the id as string, it's stored as This is restrictive but the other approach is to introduce a generic identity user type. Let's see how many 👍 we will get on this and decide based on that. |
I think it's nice to provide
Id
as a generic type parameter (or at least make it to be changed), and provide the currentObjectId
(or evenGuid
) implementation for convenience.It's currently kind of limiting for people who would want to generate their own
Id
's.The text was updated successfully, but these errors were encountered: