Closed RustyNova016 closed 11 months ago
While this more ActiveRecord style of API can be convenient, it's entirely outside of PCR's goals. The Prisma way of doing things is that data is purely data, and in my experience this is a superior approach even if it sacrifices some DX. This could probably be implemented using a custom generator (you can pretty much do anything with a custom generator), but it will not be part of PCR.
It could be really useful for APIs. If we take the same DB schema from the documentation (https://prisma.brendonovich.dev/writing-data/create), we could have an API end point that is just Post::from(request_body).create().await, which makes it really convenient.
I have other plans for how this can work, for example partial_unchecked
can already be used to go directly from request body to parameters that can be provided to update_unchecked
. I've got plans to support declaring data types with relations and create operations too.
I see. But partial_unchecked seems to be a pretty good alternative, apart when it comes to creating data, but that's just a matter of waiting for it to come. I do hope it will need less wait than waiting for Prisma to implement CUID2...
Something nice to have would be using the Data structs to modify data without having to write a query, something like
data.create()
,data.update()
, ordata.delete()
It could be really useful for APIs. If we take the same DB schema from the documentation (https://prisma.brendonovich.dev/writing-data/create), we could have an API end point that is just
Post::from(request_body).create().await
, which makes it really convenient.It could probably be done with a macro, but those are still alien to me.