https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# orm-help
  • t

    Topi Pihko

    03/30/2022, 2:39 PM
    Good evening gentlemen! Data relational question. I have following structure in DB: Factory - Site - Enterprise If I want to fetch factories of certain enterprise, is this the "best" approach? For me it looks quite ugly.
    Copy code
    async getFactories(enterpriseId: number): Promise<Factory[]> {
        return (
          await this.prisma.enterprise.findFirst({
            where: {
              id: enterpriseId,
            },
            include: {
              site: {
                include: {
                  factory: true,
                },
              },
            },
          })
        ).site
          .map((site) => {
            return site.factory;
          })
          .flat();
      }
    a
    • 2
    • 4
  • m

    Mischa

    03/30/2022, 3:37 PM
    I upgraded from prisma 3.7.0 to prisma 3.11.0 and now my app is about 5x slower when I perform queries. any idea why that might be? I tried changing only my prisma layer back from 3.11.0 to the 3.7.0 layer and the runtime performance got much better.
    👀 1
    j
    m
    j
    • 4
    • 15
  • m

    Mischa

    03/30/2022, 3:42 PM
    3.8.0 seems fine as well
  • m

    Mischa

    03/30/2022, 4:05 PM
    3.9.0 also fine
  • b

    Benny Kachanovsky

    03/30/2022, 4:39 PM
    Hi, is there a way to use
    websearch_to_tsquery
    (Postgres) search function instead of
    to_tsvector
    using Prisma?
    a
    • 2
    • 2
  • r

    Ryan Westlake

    03/30/2022, 8:30 PM
    Hey all. I’m starting a project with Prisma and loving it. The setup is: Create React App (Typescript), ExpressJs backend. It is a monorepo so the structure is like this: • Monorepo ◦ /backend ▪︎ /prisma • prisma.schema ◦ /frontend ▪︎ src • all the stuff Is there a way to share access to the prisma package/instance so that I can access the specific types in the frontend folder like I do in the backend folder (
    import Prisma, { PrismaClient } from "@prisma/client";)
    ?
    m
    • 2
    • 3
  • j

    jdkdev

    03/30/2022, 11:58 PM
    Hi had a new issue come up during seeding that was working before an upgrade, but cant tell why it wont work, It seems like Prisma is giving me a paradox of answers. If I try to create with owner it wants ownerId if I try ownerId it wants owner.
    a
    • 2
    • 9
  • t

    Torrino

    03/31/2022, 8:36 AM
    Good day! Is there a way to either: 1. Export an ENUM used as a field type on a model or 2. Import an ENUM defined somewhere in a file in the prisma scheme-a to use that enum as a field type Basically, I want to have access to enums I used as field types for my models elsewhere for additional typechecking
    n
    • 2
    • 2
  • a

    alexinfurs

    03/31/2022, 8:42 AM
    Hi all, we really want to use Prisma in our project! I want to know if there's a way to define a default filter at model level in order to automatically filter rows based to user permission (something like Laravel Eloquent global scopes). Doing this we don't need to repeat the permission filter in every query. Tnx a lot!
    n
    • 2
    • 1
  • i

    Ignace Mella

    03/31/2022, 9:34 AM
    Copy code
    model User {
      id         Int     @id @default(autoincrement())
      name       String?
      followedBy User[]  @relation("UserFollows", references: [id])
      following  User[]  @relation("UserFollows", references: [id])
    }
    Hi people, I found this part on the documentation, but I don't really get how I can just simply let a User follow and unfollow a User. What does the code have to look like?
    a
    • 2
    • 1
  • a

    Alexey Murz Korepov

    03/31/2022, 10:10 AM
    Is it possible to compose a database url string in
    schema.prisma
    file from several ENV variables? Something like this:
    Copy code
    datasource db {
      provider = "postgresql"
      url      = "postgresql://$DB_USERNAME:$DB_PASSWORD@localhost:5432/$DB_NAME"
    }
    n
    • 2
    • 2
  • l

    louis-sanna-eki

    03/31/2022, 10:11 AM
    Hi all, I'm attempting to connect Prisma to a local mongo container to run my test suite, but the connection to
    <mongodb://localhost:27017/>
    fails. Connection code (it works with a mongoAtlas db):
    const prisma = new PrismaClient({ datasources: { db: { url } } });
    await prisma.$connect();
    I'm getting errors:
    Error parsing connection string: Database must be defined in the connection string
    I'm must be missing something obvious, thx for your help.
    a
    • 2
    • 2
  • k

    Kharann

    03/31/2022, 12:33 PM
    Is it possible to prefix/suffix the types generated in prisma client? Like
    model User
    is mapped to
    PrismaUser
    rather than User. It clashes with my typings and i want an easier DX of importing types
    t
    n
    • 3
    • 6
  • s

    Saulo Aguiar

    03/31/2022, 6:31 PM
    Hi there! I’m trying to use the instrospect tool with a production ready database right now. Should it read functions and sequences (maybe triggers?) as well as tables, columns and indexes? After the introspection worked, I generated a migration by running
    prisma migrate dev
    . However, when I try to re create the database from scratch in my CI server, I get the following error:
    Copy code
    Database error:
    ERROR: relation "patient_unique_id_seq" does not exist
    I retrieved a dump from the production-ready database, and I saw that this sequence is properly defined in there. But it looks like the prisma introspection - and the migration it generated - is missing it. Any suggestions on how to fix this?
    n
    j
    • 3
    • 39
  • e

    Eme Muñoz

    04/01/2022, 4:49 AM
    Hi guys! I've been trying to handle an specific error with the code below
    Copy code
    try {
        await db.category.create({ data: fields })
        return json({ success: true })
      } catch (error) {
        return badRequest({
          type: typeof error,
          instance: error.constructor.name,
          constructorName: Prisma.PrismaClientKnownRequestError.name,
          isInstance: error instanceof Prisma.PrismaClientKnownRequestError,
        })
        // if (error instanceof Prisma.PrismaClientKnownRequestError) {
        //   if (error.code === 'P2002') {
        //     return badRequest('Category already exists')
        //   }
        // }
        // return badRequest(error.message)
      }
    But the operation
    error instance of Prisma.PrismaClientKnownRequestError
    returns
    false
    Anyone know what I could be missing? The response I'm getting:
    Copy code
    constructorName: "PrismaClientKnownRequestError"
    instance: "PrismaClientKnownRequestError"
    isInstance: false
    type: "object"
    n
    • 2
    • 4
  • m

    Marvin

    04/01/2022, 8:11 AM
    Hey! When using
    uuid
    with postgres, should I always define the db type as
    String
    +
    @db.Uuid
    ? I only have
    String
    currently and I'm not sure if prisma stores the uuid as native uuid by default?
    n
    • 2
    • 6
  • a

    aetheryx

    04/01/2022, 12:07 PM
    prisma.io is looking a bit wonky
    👀 2
    v
    j
    • 3
    • 4
  • c

    Clemo

    04/01/2022, 1:58 PM
    Hello all, I'm trying to migrate prisma to database but getting this error
    Copy code
    Error: Migration engine error: Error querying the database: Unknown authentication plugin sha256_password
    n
    • 2
    • 1
  • b

    Brendan Allan

    04/01/2022, 2:37 PM
    In this issue (https://github.com/prisma/prisma/issues/10710) it is stated that inserting many rows at a time for SQLIte ‘is not supported out of the box’, even though the workaround provided does exactly that. What is meant by this?
    a
    • 2
    • 2
  • i

    imira

    04/01/2022, 3:12 PM
    Hello. I know this question has been answered, but I think my usecase is different and I haven't found any relevant answer. I have nextjs application, prisma client instance is created based on the doc. I have DataProxy and .env config set up to use dataproxy and generated
    prisma://..
    connection string. The underlaying database is Heroku Hoby basic plan (20 connections). Everything should be ready to serverless environment but I keep receiving this error: Error: Invalid prisma.nearDailyStats.findFirst() invocation: Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 3) (edited) [4:35 PM] any idea what's the problem? Thank you
    j
    • 2
    • 7
  • o

    Orcioly Andrade Alves

    04/01/2022, 3:43 PM
    Good afternoon people, I'm developing an application in nodejs and I made the routes with JWT Token authentication, it's working normally, but now I need to make the user have access only to his data. Example: User X can only have access to his information and will not be able to access anything from another user. I'm using Nodejs with Typescript and Prisma. Could someone give me a light so I can research and implement?
    l
    g
    n
    • 4
    • 7
  • g

    Greg Ederer

    04/01/2022, 7:11 PM
    Hi, all. The Typescript types generated by Prisma don't seem to have properties for related models. Like, if a
    Person
    can have an
    Address
    , there's no
    address
    property on the generated
    Person
    type. Do I need to define my own type here, or is there a Prismaish way to handle this?
    n
    • 2
    • 2
  • j

    Jannik Köster

    04/02/2022, 1:46 AM
    hello, is the source code from prisma studio open source? I would love to see how they managed to make this amazing db ui
    n
    • 2
    • 1
  • w

    Willy Konlack

    04/03/2022, 12:44 AM
    Bonjour, j’ai un problème que je ne peux pas résoudre. J’ai ce model :model PermisConduire { id Int @default(autoincrement()) @id noPermis String @map(« no_permis ») @db. VarChar(50) dateExpiration DateTime @map(« date_expiration ») @db. Horodatage(6) Chauffeur Chauffeur? @relation("permisConduire_chauffeur") @@map(« permis_conduire ») } lorsque je migre les données de ma base de données et que je la remplis avec un « npx prisma db seed », lors de l’ajout de nouveaux utilisateurs avec prismaClient à l’aide de prisma.permisConduire.create() j’obtiens l’erreur suivante sur mon identifiant unique: « return await this.prisma.permisConduire.create Échec de la contrainte unique sur les champs : ('id')" » Par contre, lorsque je fais une migration dans ma base de données sans faire d’amorçage pour ajouter des données à ma base de données lors de la migration, je n’ai aucune erreur dans mon ajout de données avec prismaClient et la commande prisma.permisConduire.create() ? Je ne comprends pas pourquoi il se comporte comme ça, pouvez-vous m’aider? merci à tous pour vos réponses
    t
    n
    • 3
    • 2
  • p

    phil2srass

    04/04/2022, 9:14 AM
    Hello everybody ! I'm new on Prisma, very excited to integrate prisma into my projects
    🙌 1
  • p

    phil2srass

    04/04/2022, 9:14 AM
    Where is the channel to solve the issues ? For example.. I don't know how to do an inner join with include
    n
    • 2
    • 1
  • t

    This IsMe

    04/04/2022, 9:27 AM
    Hello, are there any big open source, production live, projects using Prisma I could take a look at? The app I’m creating is getting bigger and bigger and I want to take a look at what other people are doing, because I feel like my app is getting super messy 🤔
    👍 1
    n
    • 2
    • 1
  • m

    Moonchild Everlasting

    04/04/2022, 10:35 AM
    hi
    👋 1
  • m

    Moonchild Everlasting

    04/04/2022, 10:35 AM
    im trying to use a older graphql library, but it want tme to migrate
    👀 1
    v
    n
    • 3
    • 2
  • m

    Michael Roberts

    04/04/2022, 11:21 AM
    Does anyone know if the current version of prisma is well supported by the go client?
    n
    • 2
    • 3
1...559560561...637Latest