Prisma

P

Prisma

Join the community to ask questions about Prisma and get answers from other members.

Join

Error

I get a error on my data when i create a user and i saw some blogs where its cus i have information i have mandated to setup but I dont understand what it is since i basically made everything possibly optional. This is the error ype '{ email: string; balance: number; username: string; }' is not assignable to type '(Without<UserCreateInput, UserUncheckedCreateInput> & UserUncheckedCreateInput) ```js...

Prisma Migrations: local, dev and prod

Hi all, I have a specific question on Prisma migrations with next.js and Vercel. For my project I have 3 postgresQL database versions: - Local composed with docker - Dev/preview hosted on Vercel...

Prisma with cockroachDB & Deno

Hi everyone, need a little help here. I'm trying to use Prisma with cockroachDB and Deno. This is the basic schema of my app. When I try to migrate, I get the following error and I don't understand what it is. I'm running cockroachDB locally....
No description

Connect Prisma Postgres without Prisma Client?

Hi there 👋 I am right now trying out the new Prisma hosted Postgres offering. As I want to migrate a bucnh of data from my existing CockroachDB I'd love to connect with the regular psql tooling or other 3rd party SQL tools to the database. However, it seems to me that with the provided credentials I am currently required to use the Prisma client. I build a workaround for now using a seed.js script and npx prisma db seed but having access to a proper postgres connection would still be great....

Custom method in a model, gives a "not found" error

I am trying to create a custom method in my model, but when I try to use it, it says not a function. I am confused by the docs that I quoted below as the works/not works are the same code?
In the above example, prisma.user.signUp works, but prisma.user.signUp does not, because the original prisma is not modified.
https://www.prisma.io/docs/orm/prisma-client/client-extensions/model#example ...

Introspection in the client extensions

Say I have a client exension: ``` new PrismaClient({ }).$extends({ query: { $allModels: {...

how can I implement an abstract class to apply the repository pattern?

I use nestjs and would like to implement the pattern repository as it is used in typeorm ``` import { Prisma, PrismaClient } from '@prisma/client'; import { BaseInterfaceRepository } from './base.interface.repository'; ...

SSL connection to supabase

Hello, I'm developing an application where the stack includes Prisma as an ORM and the database is hosted by supabase. The app is still in development, and I'm unsure how to make the connection between the development environment and the database be SSL encrypted. That, and how to enforce it also on a production environment. As a disclaimer, I'm using: Prisma + Sveltekit + Supabase. I've also tried to put sslmode=require on the database string, but it fails to establish a connection...

How to use prisma accelerate on edge functions in local environment?

I created a local db in docker but it fails locally when the edge middleware is called.
No description

How to setup multiple Prisma clients in combination with `prismaSchemaFolder`

I'm trying to setup multiple Prisma clients (as I have 2 sperate databases) in combination with prismaSchemaFolder. As I'm having 2 Prisma clients I need to define the ouput folder manually like: ``` generator client { output = "../../../node_modules/@prisma/db1/client/"...

Prisma return model type

Hey! I might be missing something, but how can i actually use the Model type from the prisma client? Prisma seems to be returning a full on object instead of the prisma model type, theres any type utility or something around this?

Cache invalidation across different repositories

Is it possible to invalidate cache across different codebases that use the same Accelerate connect URI? Let's say that multiple microservices can manage articles collection in Mongo and they use TTL cache with articles tag. Does invalidate() call for that tag in one codebase also invalidate the cache in all codebases?...
Solution:
Hello @Ved 👋
the same Accelerate connect URI
If both codebases are using the same Accelerate connection string then yes, an invalidate call will invalidate cache across all codebases....

link local prisma database project into other projects

Question I have two services that is in need of my prisma project that has all the types and prisma client, now I need a way to install it into both projects. My database project only has one file prisma.ts that exports the prisma client, I also need the types of my models as well. my database project package.json { "name": "pricing-oygula-database",...

Lambda Layer

Hello, im trying to reduce my cold start. i use prisma in a lambda layer. currently its copying these folders. do i need all of them? any resources i can read more about what to include?
No description

D1 Database?

Hello, just a quick question please. Does Prisma support D1 Database from Cloudflare?

Wrong types for optional fields

Hi everyone, I searched a lot about my issue but could not find a solution yet and I was hoping for some expert advice in here! It's about generated typing of Prisma optional fields in schema. It seems that for Prisma they are always there while they could be null :thinking: , for example: export type Booking = Prisma.BookingGetPayload<{...

How to filter table for json data?

i got this ```ts async function getData() { const data = await prisma.assets.findMany({ where: {...

CTE query not working properly

Look at attached photo for error code and query. This query works when running against local DB, but doesn't work when running against deployed DB. I'm able to run this query against both DBs using raw sql outside of Prisma. I'd love some help here!...
No description

Prisma extension as a Middleware to update a count

In my app, I want to keep track of the numbers of "posts" published by the user. Instead of computing them on request, I want to keep the value on the database, updating every time the user publish a new post. To do that, I am using prisma extensions. But:...

Validate Model

Problematic I would like to use Prisma.validator (or something else provided by Prisma) in order to validate a model Context ```ts...
Solution:
Finally created a function that answers this question in case anyone needs it ```ts export type GetModel<T extends Prisma.ModelName> = Exclude< Awaited<ReturnType<PrismaClient[Uncapitalize<T>]["findUnique"]>>, null...