prisma-client-go
prisma-client-go copied to clipboard
Stripped json
When working on Select statement I noticed that the returned json contains a lot of empty fields. Perhaps not a problem, but I like my json neat and tidy.
For instance, when using Select I get this:
i.e. overview, still etc are null, empty strings etc.
I've created an ExecJson-function (to be used instead of Exec) that returns the following json
The one downside is that since we retrieve the data as json we can't do any manipulation (unless, of course, we unmarshal it, but that negates the whole thing), but if we just want to retrieve slim data this might be an idea?
Can you elaborate what you are using this function for? Like why do you want to get raw json data instead of a type like User?
Also, can you elaborate what the exact signature of ExecJson would be?
I'm coming from a frontend perspective where I want to download as little data as possible. Ffor instance, in my pet project that I'm porting from express/nodejs I've got 900+ movies with videofiles, cast, crew, genres and details. Things can quickly add up.
The signature I'm using is: ExecJson(ctx context.Context) (j []byte, err error)
So I use it like: movies,err := db.Movie.... Select([]string{"title,"id"] ExecJson(context.Background())
w.Write(movies)
This is now available in the main branch, you can try it out by running go get github.com/prisma/prisma-client-go@main
. It's not yet released, but I'll cut a new one soon!