prisma-client-go
prisma-client-go copied to clipboard
Generate models into separate `models` package
When querying for data, we already use the uppercase model name such as User
for the query builder. This means we can't use the same name from the same package as a return type (e.g. of a FindOne
call), which is why these types are currently suffixed with Model
, such as UserModel
. We could move those to a models
package inside of whatever output folder is specified for the go client.
So, instead of:
func (x X) getUser() (prisma.UserModel, error) {
return x.prisma.User.FindOne(
db.User.ID.Equals("hi"),
).Exec(ctx)
}
the code could look like:
func (x X) getUser() (models.User, error) { // models: return type
return x.prisma.User.FindOne(
db.User.ID.Equals("hi"), // db: query builder etc.
).Exec(ctx)
}
I like this. More concise api