Entity in Typescript does not have all properties
I have this entity
and a query to get modules from a user
but when I use this on the frontend, it returns an entity that does not match the prisma entity. It is missing the
tasks
, user
, and notebooks
properties.12 Replies
In your return statement, add a ‘select’ property and explicitly state the Module fields you want returned, e.g:
where: {},
select: {
id: true,
…
user: true,
tasks, true,
}
Thanks
did that work?
yep
Wohooo @MrDiamond, you just became a Waspeteer level 1!
@Vinny (@Wasp) so prisma by default returns no fields? Interesting, I thought that by default it would return all of them!
i think it just doesn't return lists by default. not sure
this might actually be a better solution;
It didn’t include
user
by default so it looks like it only includes primitive types by defaultright that makes sense! These are connections at the end so they are more expensive to fetch
right, Prisma by default does not include any connections, you have to specify which one you need. And it's pain when you have self-relations e.g. categories, you have to specify which depth level you need even though you can't know it at compile time if you need all of them
Ouh blurgh! What do they say, do they have any solution in the plans for this?
I found an issue from 2020 related to this https://github.com/prisma/prisma/issues/3725, it is upvoted enough but didn't receive any feedback from Prisma team neither there is something similar in their roadmap
https://pris.ly/roadmap
GitHub
Issues · prisma/prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB - Issues · prisma/prisma
Prisma on Notion
Prisma ORM Roadmap
Our roadmap shares our current priorities. It displays an Initiatives board, showing what we are currently working on, and plan to do next.