Mooncäke
PPrisma
•Created by Mooncäke on 6/13/2024 in #help-and-questions
Import Enum from my TS to the schema
Hey,
Wanted to know if it's possible to import an enum inside my
schema.prisma
file instead of defining it inside ?
Because all my types used by both front & back are located to a dedicated package, and it actually force me to define my enum in 2 distinct places, where I would like to only have it in my types package.
Thanks!3 replies
PPrisma
•Created by Mooncäke on 6/12/2024 in #help-and-questions
Export client types in custom package
Hi,
Actually I have a project in a monorepo, with a app/ folder and api/ folder. My API folder contain a node project that runs a web server, and also contains my prisma install.
Now that i'm setting up the front, I would like to use the sames types as my back, but can't see a good solution to to that.
My goal would be to have a types/ folder at the same root as my both projects, that is literally a node_module that contains all types that i want to use across projects. I tried to create a 2nd Prisma client that generate inside this folder, but when I try to build my package with a simple file that `export * from "myCustomPrismaClientPath/index", it throw me a lot of typescript error because it can't find packages like @babel/types or "undici-types".
Do you guys have any idea or suggest to fix that ?
2 replies
PPrisma
•Created by Mooncäke on 5/27/2024 in #help-and-questions
Extend client Type loose relation
Hey there, i'm having some trouble when I extend a Prisma client type (in typescript). I have a User, which have a oneToOne relation with a Preferences model, looking like that:
I made this interface:
And I have a function that find a user, aggregate it in a new object with roles array, and the output of this function seems to drop the preferences relation, even if I explicitly include it in my findUnique function. Not an expert in typescript yet, so I may miss something basic, but it should works from what I understand.
Need a lil help on that one please,
Thanks !
5 replies
PPrisma
•Created by Mooncäke on 4/24/2024 in #help-and-questions
Extends result relations
Hi,
I have 3 different objects:
The last one have a manyToOne relation for both User & Exoskeleton.
My goal is to add a custom field to User, named
currentExoskeleton
, based on the relation to exoskeletonAttribution (i take the last in date), to fetch to associated Exoskeleton.
So i started to wrote this:
But typescript already crying on me on the needs part, "impossible to align type boolean to never". And i would also like to know if it's possible to user async/await on compute ? (if yes, how ? should i return an async function from the compute function ?)
Thanks 😉2 replies