Skip to content

Instantly share code, notes, and snippets.

@juliankoehn
Created June 17, 2020 11:31
Show Gist options
  • Save juliankoehn/5b0ae858210659373fb3a36921dd7acf to your computer and use it in GitHub Desktop.
Save juliankoehn/5b0ae858210659373fb3a36921dd7acf to your computer and use it in GitHub Desktop.
ideas for the prisma go client
package prisma
type EntityQuery struct {
QueryInterface
}
// implementing into model struct
// not as INTERFACE, to use inheritance.
// we can still customize funcs if needed
// on model level
type QueryInterface struct {
Set(value string) SetParams
SetOptional(value..) SetParams
Equals(...) ParamInterface
In(values ...string) ParamInterface
}
// EntityName is set on EntityQuery
func (*EntityQuery) EntityName() string {
return "entityName"
}
[...]
func (q EntityQuery) Set(value string) SetParams {
return SetParams{
data: builder.Field{
Name: q.EntityName(),
Value: value,
}
}
}
[...]
// Generated Code =>
// type localeParams struct {
// data builder.Field
// query builder.Query
// }
//
type EntityParams struct {
ParamInterface
}
// returns exactly the same among all models
// if funcs should be differnt, they still can be overwritten
type ParamInterface struct {
data builder.Field
query builder.Query
}
func (*ParamInterface) field() builder.Field
func (*ParamInterface) getQuery() builder.Query
func (*EntityParams) entityModel()
type SetParams interface {}
@juliankoehn
Copy link
Author

=> missing interface implementations... <.<

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment