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

    Charles Gaudreau Jackson

    11/26/2021, 8:34 PM
    Hi! What is the best way to secure my GraphQL endpoint? I wouldn’t want users to query and mutate data by accessing my playground. I am using Apollo! Thank you!
    r
    c
    • 3
    • 3
  • r

    Renato Carneiro

    11/26/2021, 9:21 PM
    Anyone have trouble with Intellij IDEA not picking up prisma schema changes on PrismaClient? I'm having to fully restart the IDE when I change anything on schema...
  • i

    Italo Gama

    11/27/2021, 1:45 AM
    Hello guys! i’m a beginner on Prisma, can someone help me?
  • i

    Italo Gama

    11/27/2021, 1:46 AM
    https://stackoverflow.com/questions/70131425/nestjs-prisma-how-to-create-record-with-relational-fields
    r
    • 2
    • 4
  • w

    Wingy

    11/27/2021, 3:33 AM
    Is it possible to interpolate bigints with Prisma#join? I'm not getting my data back if i use bigints, but i do with normal numbers, but some ids might be higher than max safe integer
    r
    • 2
    • 2
  • t

    Taylor Cantwell

    11/27/2021, 6:48 AM
    Hi guys, quick question, anyone know why my TS types are being split between “.prisma/client” and “@prisma/client”? For whatever reason the model types are being placed in “@prisma/client” whereas the input types are being placed in “.prisma/client”? The docs demo them being both pulled from “@prisma/client”.
    r
    • 2
    • 1
  • u

    user

    11/27/2021, 1:22 PM
    Server less, Code more - Aydrian Howard - Prisma Serverless Conference

    https://www.youtube.com/watch?v=iPxuyWSExqw▾

    With Serverless deployment you want to focus on the code and nothing else. You need a scalable backend that can provide low latency, always-on experience for your applications. CockroachDB Serverless gives developers instant access to an auto-scaling SQL database that they can spin up in seconds without having to worry about hardware details or capacity planning and pay only for what they use. This talk is geared towards developers looking to streamline the developer experience and time to ship with JavaScript, Prisma, and CockroachDB Serverless. With CockroachDB Serverless, developers can build what they dream of without worrying about their database. 🗣️Speaker: Aydrian Howard Aydrian is a Hoosier living in the big city. He enjoys mentoring at hackathons and live coding on Twitch. Aydrian began his career helping bring technology to schools by setting up computer labs and training teachers and staff. Connect with Aydrian: https://www.linkedin.com/in/aydrian/ 📣 Prisma Serverless This talk has been recorded at the Prisma Serverless Conference on November 18, 2021. You can learn more about the Prisma Data Platform here: www.prisma.io/dataplatform
  • b

    Brook MG

    11/27/2021, 3:52 PM
    Hey guys , how far off is native PostGIS support in prisma?
    m
    • 2
    • 1
  • c

    Carlos

    11/27/2021, 4:26 PM
    Hello everyone, Anybody has any idea of how to work with "user fields" in Prisma. In my application, customers (Tenants) should be able to create their own columns in the table without affecting the Prisma Schema. Base system columns cannot be modified, however, customer can add new columns example: Ticket number, reference or anything they want which is only used in reports. Is it possible to mark some columns as "*Ignore*" or "*Not Manage*" in Prisma so that they are skip when performing migrations, db pull and prevent prisma from throwing errors?
  • j

    Jinho Chung

    11/27/2021, 11:38 PM
    Hi, I just installed Prisma and added it to an existing postgres database. I was following the quickstart guide for existing SQL projects, and at the end it suggests that to evolve the project, changes should be made in the database,
    prisma db pull
    should be evoked followed by
    prisma generate
    . Is this a common pattern? Does this suggest that if prisma is being added to an existing database, that migrations should not be used?
    r
    • 2
    • 3
  • v

    Vinicius Marchesin

    11/27/2021, 11:55 PM
    Hey everyone 👋 Probably a stupid question but I can't seem to figure out how to do it. I have this schema.
    Copy code
    model Community {
      id           String                     @id @unique @default(uuid()) @db.Uuid
      regions      Region[]
      ...more stuff here
      members      UsersOnCommunities[]
    }
    
    enum Region {
      NA
      EU
      LATAM
    }
    
    model User {
      id               String               @id @unique @default(uuid()) @db.Uuid
      ...more stuff here
      communities      UsersOnCommunities[]
    }
    
    model UsersOnCommunities {
      id           String    @unique @default(uuid())
      userId       String    @db.Uuid
      communityId  String    @db.Uuid
      ...more stuff here
      community    Community @relation(fields: [communityId], references: [id], onDelete: Cascade)
      user         User      @relation(fields: [userId], references: [id], onDelete: Cascade)
    
      @@id([userId, communityId])
    }
    I want to find find many communities where
    region: ['NA']
    and the count of members is greater than
    n
    . I am using
    Copy code
    const data = await prisma.community.findMany({
            ...my pagination here,
            where: {
              regions: {
                hasSome: regions,
              },
            },
            include: {
              _count: {
                select: {
                  members: true,
                },
              },
            },
          });
    With this I am able to get the count of members, but I can't filter by that. From the docs it looks like I need to use
    groupBy
    and filter using
    having
    , but how can I get all fields back from the group by that way? Not sure what's the best way to do this besides a raw query.
  • k

    Kunal Shah

    11/28/2021, 3:36 AM
    Hey all 👋 I have a quick question regarding type-checking. When I pass a restructured object to an
    update
    call
    Copy code
    const data = await prisma.document.update({
        where: { id },
        data: {
          ...params,
          // updated_at: new Date(),   // when this is uncommented, type-checking fails
        },
      });
    it correctly highlights that
    params
    is not the right type to update the document. However when I uncomment the
    updated_at
    line, the errors go away and it fails to typecheck at all. Any idea what I am doing wrong here? thanks in advance!
    a
    p
    m
    • 4
    • 7
  • r

    Robert Fish

    11/28/2021, 2:06 PM
    Hi all i was wondering if prisma supports database listeners for live updates when data changes? 😄
    r
    • 2
    • 1
  • b

    Benny

    11/28/2021, 2:46 PM
    Hi! We have a monorepo and as part of the
    prepare
    script of one of our libs we want to run
    prisma migrate dev
    . We are getting
    Copy code
    Error: Prisma Migrate has detected that the environment is non-interactive, which is not supported
    Is there a way to automatically accept the migrations? What is the best practice here?
  • b

    Benny

    11/28/2021, 2:51 PM
    prisma db push --accept-data-loss
    is the way to go?
  • b

    Benny

    11/28/2021, 3:05 PM
    ah it wont create migrations 😞
  • b

    Benny

    11/28/2021, 3:14 PM
    So my colleagues are changing the Prisma schema and then they push it. We want to pull it from git and automatically generate the client code (that is under .gitignore obviously and reflect the changes to the local db). So as far as i understand the way to do it is: 1. Add
    prisma db push --accept-data-loss
    in
    npm prepare
    script that will apply the changes that were pulled (because when pulling we are running
    pnpm i
    that will eventually trigger
    prepare
    .) 2. When changing the schema locally, before pushing, we have to run
    prisma migrate dev
    to generate migration files. Is this the correct flow?
    r
    • 2
    • 1
  • j

    joao.santos

    11/28/2021, 4:05 PM
    Hi guys does any know a repo or a example code for seeding a complex db?? Thx
    m
    • 2
    • 2
  • g

    glenn

    11/28/2021, 6:38 PM
    Hi everyone. I'm trying to use $queryRaw that uses a function I made in postgres
    Copy code
    await prisma.$queryRaw`SELECT * from job_search_db.jobs_function(
    				${distanceInt}, 
    				${dateRangeStr}, 
    				${remoteBoolArr}, 
    				${citiesArr}, 
    				${termsArr}, 
    				${excludeTermsArr}, 
    				${excludeCompaniesArr}, 
    				${jobBoardsArr}, 
    				${orderBy}, 
    				${limitInt}, 
    				${offsetInt}
    			)`
    when I format it like this I get: db error: ERROR: number of array dimensions (1634890337) exceeds the maximum allowed (6) However, when I just log the query that I placed in a variable then paste the query in hardcoded it works and returns the expected results
    Copy code
    const result = await prisma.$queryRaw`SELECT * from job_search_db.jobs_function(
    				50000, 
    				'2021-09-29T17:24:58.142Z', 
    				array[true, false], 
    				array[4560349,5128581,5205659], 
    				array['%javascript%','%react.js%'], 
    				array['%junior%','%jr%','%manager%','%analyst%','%recruiter%','%accounting%','%network%','%associate%'], 
    				array['cybercoders'], 
    				null, 
    				'desc', 
    				26, 
    				0
    		)`
    I don't really understand why
    r
    • 2
    • 3
  • j

    Julien Demarque

    11/29/2021, 11:55 AM
    Anyone has tried full-text search on json field? seems not to work for me...
    r
    • 2
    • 2
  • u

    user

    11/29/2021, 12:18 PM
    TypeScript Berlin Meetup #8 - Iván Ovejero - Distributive conditional types

    https://www.youtube.com/watch?v=JiLoWPwhTf0▾

    ◭ In this talk, Iván will delve into distributive conditional types and what they are good for, as an example of how thinking of types in terms of sets can help us gain fluency in manipulating everyday types. ◭ Iván is a Full-Stack Developer at n8n.io, a workflow automation startup in Berlin, formerly a fellow at Major League Hacking. He enjoys exploring all kinds of TS projects and has built many of his own, including a linter with the TS compiler API and a code generator with TypeScript AST transformers. ◭ Get in touch with Iván: https://github.com/ivov ◭ Join our TypeScript Berlin Meetup group: https://www.meetup.com/TypeScript-Berlin
  • i

    Italo Gama

    11/29/2021, 3:31 PM
    Hello guys. I’m from Brazil and i’m about to do a job developer interview in some days and i was wondering if someone would be abble to talk to me to give me some tips on English. I have a “ok” conversation but i want to improve some more. I’m really looking foward for this job. Thank you guys!
  • j

    James Homer

    11/29/2021, 3:39 PM
    Hello, is it possible to orderBy a value in a JSON field?
  • j

    James Homer

    11/29/2021, 3:42 PM
    nvm https://github.com/prisma/prisma/issues/10346
  • c

    Chris Bitoy

    11/29/2021, 4:12 PM
    Hello guys. I’m a newbie to Prisma, and would like to get some help connecting multiple tables - Anyone here a Prisma ninja?
    m
    • 2
    • 19
  • b

    Benny

    11/29/2021, 4:41 PM
    Hi, is there a way to generate enums as typescript enums instead of unions or consts?
    r
    • 2
    • 1
  • i

    Italo Carrasco

    11/29/2021, 6:49 PM
    hello everyone i have a question about nested relations, this is my simplified model:
    Copy code
    model Notaria {
      idNotaria      Int      @id @default(autoincrement())
      idEstado       Int
      razonSocial    String   @db.VarChar(255)
      codigo         String   @db.VarChar(255)
      createdAt      DateTime @default(now())
      updatedAt      DateTime @updatedAt
      estado         Estado   @relation(fields: [idEstado], references: [idEstado])
    }
    
    model Estado {
      idEstado Int       @id @default(autoincrement())
      nombre   String    @db.VarChar(255)
      Notaria  Notaria[]
    }
    i am trying to use create like this but it throws an error related to data saying: type number is not assignable to undefined
    Copy code
    crearNotaria: (_parent: any, args: CreateNotariaInput) => {
          return prisma.notaria.create({
            data: {
              ...args,
              estado: { connect: { idEstado: args.idEstado } },
            },
          });
        }
    if i change the code to this, the error goes away. i dont understand why the first method doesnt work or what am i doing wrong.
    Copy code
    crearNotaria: (_parent: any, args: CreateNotariaInput) => {
          return prisma.notaria.create({
            data: {
              ...args,
              idEstado: args.idEstado,
            },
          });
        }
    ✅ 1
    k
    • 2
    • 2
  • m

    Marcus Y.

    11/29/2021, 7:19 PM
    Hi, I have a question regarding two models which are not related to one another: This is my model:
    model Newsletter {
    email String @unique
    }
    model User {
    id              Int           @id @unique @default(autoincrement())
    config          Configuration @relation(fields: [configurationId], references: [id])
    records         Record[]
    information     Information   @relation(fields: [informationId], references: [dbid])
    informationId   String
    affirmations    String?
    configurationId String
    recaps          Recap[]
    lastIndex       Int?
    }
    I create a new Newsletter record by running:
    return await server.db.newsletter.create({
    data: {
    email: args.email,
    },
    });
    It returns:
    PrismaClientKnownRequestError:
    `Invalid
    prisma.newsletter.findFirst()
    invocation:` `Failed to validate the query:
    Field does not exist on enclosing type.
    at `Query.findFirstNewsletter``
    at cb (/Users/*/*/*/*/node_modules/@prisma/client/runtime/index.js:38675:17)
    at Object.addEmailToNewsletter (/Users/*/*/*/*/src/resolvers/addEmailtoNewsletter.ts:7:16) {
    code: 'P2009',
    clientVersion: '3.5.0',
    meta: {
    query_validation_error: 'Field does not exist on enclosing type.',
    query_position: 'Query.findFirstNewsletter'
    }
    }
    Any idea how to resolve this?
    g
    r
    • 3
    • 3
  • z

    Zak

    11/29/2021, 9:24 PM
    InvalidDatasourceError: Datasource URL should use prisma:// protocol What could be causing this when running “prisma db push && prisma db seed”
    r
    • 2
    • 7
  • m

    Michael Aubry

    11/29/2021, 9:44 PM
    When I generated my schema for id’s on my model I am using `cuid`https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#cuid
    Copy code
    id String @id @default(cuid())
    Then the column is forced to 25 chars, but the docs say it can be up to 30, and I am running into a column too large issue. What is the best way to update the column char count to 30? Why did it generate at 25?
    Copy code
    id character(25) PRIMARY KEY,
    Copy code
    -- DDL generated by Postico 1.5.19
    -- Not all database features are supported. Do not use for backup.
    
    -- Table Definition ----------------------------------------------
    
    CREATE TABLE graphcool."Media" (
        id character(25) PRIMARY KEY,
        createdat timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
        updatedat timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
        date timestamp with time zone,
        duration double precision,
        loading boolean NOT NULL,
        mediaurl text,
        name text,
        thumbnails text,
        trimmed boolean,
        type text,
        uid text,
        "thumbnailSprites" text,
        metadata text
    );
    
    -- Indices -------------------------------------------------------
    
    CREATE UNIQUE INDEX idx_17956_primary ON graphcool."Media"(id bpchar_ops);
    CREATE UNIQUE INDEX idx_17956_id_unique ON graphcool."Media"(id bpchar_ops);
    r
    • 2
    • 1
1...512513514...637Latest