Nik
PPrisma
•Created by Nik on 8/9/2024 in #help-and-questions
Query fields on an object
Given my prisma schema:
I am looking to make a query on the zip code, quite simple requirement.
However, Prisma isn't allowing this to happen:
let dominantZipAddresses = await database.feature.findMany({where:{
properties:{postcode: dominantZip}
}});
This fails because it expects id, unit, etc. to also be included with the postcode. But for a query that makes no sense. Without defaulting to raw queries, how can I accomplish this?
2 replies
PPrisma
•Created by Nik on 5/6/2024 in #help-and-questions
Convert Raw Query back to prisma type
Is there any utility function to convert the result of a raw query back to prisma types?
2 replies
PPrisma
•Created by Nik on 4/24/2024 in #help-and-questions
How to type $allModels result extension
I have the following simple example of a result extension:
However on all my modelsI can't even call it. It just says type never has no call signatures
2 replies
PPrisma
•Created by Nik on 4/17/2024 in #help-and-questions
prisma aggregateRaw, how to parse Date back to javascript date, and other special types,
Unfortunately I've been forced to use aggregateRaw because I run into memory limits that requires the "{ allowDiskUse: true }".
How can I either:
1) Add this option to regular queries
or
2) Have aggregateRaw parse back to javascript types.
2 replies
PPrisma
•Created by Nik on 4/16/2024 in #help-and-questions
Add Model Extension methods
Hey so I'm using Prisma client extensions to add some methods to my instantiated database objects.
However I find cases where either some external force strips the methods off the object or I need to. I would like to be able to reattach them.
Is there a way to do this? Like run the model through a Prisma.applyExtensions(modelName, data)
or maybe extendedPrismaClient.enhance(data)
1 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
[Typescript] Prisma result extension typing
How can I get proper typing in a prisma result extension for $allModels? For a simple example, I want to return the same type available in a Model.create for any model
1 replies
PPrisma
•Created by Nik on 4/15/2024 in #help-and-questions
@unique on optional field
and
As you can see, user_id is an optional field. However the relation REQUIRES it to be marked as unique. In doing so, I get the following error: duplicate key { user_id: null }
I imagine this will be an issue for excluded emails too, though I haven't run into it yet
20 replies
PPrisma
•Created by Nik on 4/7/2024 in #help-and-questions
Update nested field in composite types
I have a deeply nested structure. It has to be this way.
I want to update a single field at the end of the nested tree structure. How do I accomplish this?
3 replies
PPrisma
•Created by Nik on 3/31/2024 in #help-and-questions
[ADVANCED] Prisma Extensions - dynamic typing
I'm trying to create a $allModels extension with proper typing and have been struggling.
This is what I was able to cobble together:
There are a few issues I want to resolve here:
1) There has to be some better typing for the ctx (or accessing the parent model).
2) I want to have an includes parameter, and return dynamic typing much like a regular .findFirst query. How can I achieve this? The only thing I can think of is that undefined Result generic which i can't seem to figure out what it does.
Thanks
3 replies