Open Weakky opened 5 years ago
<create|read|update|upsert|delete><M|M Plural>
t.crud.createUser()
t.crud.readUser()
t.crud.readPosts()
t.crud.updateUsers()
t.crud.deletePost()
<M>.<create|read[Many]|update[Many]|delete|upsert>
t.crud.user.create()
t.crud.user.read()
t.crud.user.updateMany()
t.crud.post.readMany()
t.crud.post.delete()
<M>.<create|read|update|delete|upsert>
t.crud.user.create()
t.crud.user.read()
t.crud.user.update({ many: true })
t.crud.post.read({ many: true })
t.crud.post.delete()
<M>.[many.]<create|read|update|delete|upsert>
t.crud.user.create()
t.crud.user.read()
t.crud.user.many.update()
t.crud.post.many.read()
t.crud.post.delete()
I think the presence of read
in the API
I am not sure the assumption baked into t.crud.user.update({ many: true })
is optimal, which is that, [almost] all many-enabled CRUDs will have single-enabled too.
We could allow: t.crud.user.update({ many: true, one: false })
to break the assumption.
A nice thing about this API is that for each resource type (user
, post
, etc.) there is exactly one entry for each C.R.U.D dimension. The more I think about this the more I like it. The reason is, the emphasis on facts.
Casting ii
as config within i
feels appropiate.
We could support operation publisher option configuration like so:
t.crud.user.read({ many: { filtering: true, pagination: false }})
Proposal 2 seems beautiful, vote for it.
t.crud.user.read()
t.crud.post.readMany()
I get the domain: user
, then I want to execute some actions against it, this fits the mantle model of writing code.
For each action, 2 versions, single and many. Especially when using Typescript, the auto-completion will be perfect, you type rea
, then both read
and readMany
would pop up. And this is one of the reasons it is better than proposal 1, which is, for proposal 1, after typing creat
, there will be too many options once there are enough models. But for proposal 2, the filtering has already been done after doing t.crud.user
.
For proposal 3, pass the many
intention as a parameter is fine, but semantically, read
and readMany
seems to have a more readable experience and nicely decouple to me.
Not a big fan of proposal 4, as proposal 2 fulfills the same requirement, but open to hear more.
Description
Which naming convention do you prefer for mutations:
create/update/deleteOneSomething
create/update/deleteSomething
?I personally prefer create/update/deleteSomething, that's how it used to be on Prisma 1. We already updated
Query.findOneSomething
andQuery.findManySomething
toQuery.something
&Query.somethings
. It'd probably feel better to follow the same patternRelated to #388