Monorepo setup: Prisma with NestJS
I currently have a postgres database that uses row level security. This database is used by two services that are built with NestJS.
- auth service
- core service
...
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?...
How to use enum?
I'm using Next.js and TypeScript for my project, but I'm getting an error when I attempt to call prisma create.
Error: Type 'string' is not assignable to type 'Status | undefined'.ts(2322)
```tsx
// page.tsx
const [name, setName] = useState('');...Turbo setup with prisma and pnpm
I have a setup using turborepo and running a few apps and some shared packages together and it works well in dev but i can't figure out how to setup docker, pnpm and prisma together. I've written my dockerfile below and my tree structure is
Prisma;
/apps/qrtag/prisma/prisma.schema
...
Prisma new field adding will thorw the unkown error
```sql
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
hashedPassword String...
Check constraint migration fails with syntax error
I made the following migration file and ran the migration:
```sql
ALTER TABLE "api_owner"
ADD CONSTRAINT "check_owner_one_null" CHECK (user_id IS NOT NULL AND organization_id IS NULL) OR (user_id IS NULL AND organization_id IS NOT NULL);...
Optimizing a query
I currently have the following code to update the pricing of the items in the database:
```ts
const prismapromises = Object.keys(items).map((item) =>
prisma.minion.update({
where: { id: item },...
Raw query doesn't work
``js
let result: any = await this.prisma.$queryRaw
select V.name, V.id, SUM(O."amount"::BIGINT)::BIGINT
from "Variety" V
left join "Flower" as F on F."varietyId" = V.id...how to make onDelete: SetNull only work for one field
I have a relation which has 2 fields, one being optional and one is a required field, how do I make my schema so that when the referenced model is deleted it only sets the optional field to null?
Cursor based pagination without numeric id available in table
When using cursor based pagination (https://www.prisma.io/docs/orm/prisma-client/queries/pagination#cursor-based-pagination) what if a table has no sequential number?
Imagine a Person table with an id which is a guid, or maybe just in the format
'firstname-lastname' (like 'vivian-defoe').
And then I would like to do cursor based pagination in combination with an user supplied order (like via a REST api users can provide the sorting option like first_name, last_name, gender, date_of_birth, place_name_of_origin.
Is that possible, or should I use offset pagination in that case?...Cloudflare D1 support
Hi, I've searched the server for this and found an answer from Nurul 2 months ago saying this feature is planned.
From what I've seen you guys don't like to share ETAs so instead could you just tell me if works on this has been started or not?
Thanks! Looking forward to this...
I need to convert find many query to find raw query...
@kapa.ai
await this.prisma.incident.findMany({
where: {
title: { contains: filter?.title },...
UpdatedAt value changes if no field value changes?
What happens to the UpdatedAt field, if I over write a value of a field and no other fields value is changed. Does the updatedAt fields value reflect the current datetime or it remains unchanged?
Example, there is a flag field, with value 1. I perform a update on that record and still assign 1 as value to the flag field. Nothing else changes. Does the updatedAt fields value automatically get updated or it does not change - as non of the value in the record actually changed....
[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:
```
model: {...
Filter: return both or one
I have the case where I want to narrow the search with 2 keywords, 2 keywords work, but 1 alone is not working. I have tried:
```
where: {
AND: [{ type: { in: input } }, { priceType: { in: input } }],
OR: [{ type: { in: input } }, { priceType: { in: input } }],...

Cannot select both '$scalars: true' and a specific scalar field 'tags'.
This is my relevant schema
```
model EventTag {
id Int @id @default(autoincrement()) @db.UnsignedInt
eventUserId Int @db.UnsignedInt...
what is the error code for
Unknown field
asdf for select statement on model Blogs. Available options are marked with ?.
error in prisma?...[ACCELERATE] Timed out fetching a new connection from the connection pool
I'm using Prisma Accelerate with the @prisma/client/edge client and I'm getting the following error:
``zsh
10:48:02 AM [vite] Internal server error:
Invalid prisma.facility.count()` invocation:
...