Skip to content

How can I implement default for something generated by the client? #100

Answered by Brendonovich
Milo123459 asked this question in Q&A
Discussion options

You must be logged in to vote

More or less you can't. I purposefully don't implement Default since that's out of scope of Prisma Client Rust, plus even if it did I'd argue that in your case it isn't helpful, since the ID of the user data wouldn't be equal to user_id (unless you reassign it).
You can implement Default manually yourself if you really want to, but I think a better solution is to create a custom struct that you can convert user_data::Data to, and then derive Default on it.
You can also create an instance of user_data::Data and specify all the parameters yourself but I imagine that's not a great experience.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Milo123459
Comment options

@Brendonovich
Comment options

Answer selected by Milo123459
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants