Allow select as alias custom field name and exclude some fields in prisma client
See original GitHub issueProblem
In prisma client 2.26 and sqlite, its not every efficient to run map, reduce server side functions to rename keys in data from prisma.
If prisma is getting upwards of five different relations, I would rather directly setup aliases, custom field names directly in the query than external code
similarly, if a table has a lot of field names, theres no clear way to exclude few while selecting all others.
I dont want to explicitly name every field in the prisma query if I need to select only 24 out of 25 fields in the model relation
Suggested solution
I am looking for the prisma equivalent of
SELECT party_id as id FROM genres
and
SELECT * EXCEPT id
FROM (...) genres
and somehow apply it across multiple relations in findMany starting example
var tv_shows = await prisma.tVShow.findMany({
include: { genres: true, production_companies: true, seasons: { include: { episodes: true } }, credits: true, similar: true }
})
Alternatives
Doing an external code implementation using map
, reduce
to transform the selected object
ie
genres.map(item => {item.id = item.party_id; delete item.id;})
Additional context
related thread https://github.com/prisma/prisma/issues/4433
Issue Analytics
- State:
- Created 2 years ago
- Reactions:27
- Comments:7 (1 by maintainers)
Top GitHub Comments
I don’t know if it is the same issue, but I would love to be able to alias (rename) relations as well.
For example, what I would love:
Please, Add an alias feature to Prisma