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

    Manthan Mallikarjun

    06/12/2021, 2:52 AM
    For example,
    prisma.posts
    is in reality an object with a create function, update function, etc
  • m

    Manthan Mallikarjun

    06/12/2021, 2:52 AM
    is there a way to get a generic version of that object
  • m

    Manthan Mallikarjun

    06/12/2021, 2:53 AM
    i want to make a small utility library
    r
    • 2
    • 1
  • e

    ehiz_briel

    06/12/2021, 4:57 AM
    Hey, I don’t know if anyone is still using prisma1. Am kinda new to this and am having issues with it. Am trying to connect to an existing Postgres db and after following the prompts with prisma1 init none of the usual files are generated
  • l

    Lars Ivar Igesund

    06/12/2021, 7:06 AM
    @ehiz_briel quite a few do, see the #prisma1 channel. Don't remember much about prisma init though, been a while 🙂
    e
    • 2
    • 1
  • j

    jasci

    06/12/2021, 12:38 PM
    Hello everybody, can you please tell how to properly provide values of type DateTime(Postgres) through prisma client? String, int, and instances of Date don’t seem to work.
    r
    • 2
    • 2
  • m

    Matias Martinez

    06/12/2021, 3:16 PM
    Hello guys!! I hope everyone is doing fine!! Does anybody have an issue with this https://vercel.com/guides/nextjs-prisma-postgres ? I followed the instructions like that but for some reason, I can't create a draft..., if I go to Prisma studio I can create a new post and delete it, but it seems the front-end connection is not working .. thank you!!
    d
    • 2
    • 2
  • a

    Albert Gao

    06/12/2021, 11:43 PM
    For
    Json
    • If I have a field like
    data Json
    , in the runtime, the data will be something like:
    [{},{}]
    , should I type this field as
    Json[]
    then? json can be an array, but what prisma is expecting here? currently,
    Json
    works perfectly fine though • I constantly getting this error:
    Index signature is missing in type BlahBlah
    when saving against a
    Json
    type field, so basically, I need to extends my type with an object type with index, is this recommended ?
    r
    • 2
    • 1
  • j

    Justin Sunseri

    06/13/2021, 2:34 AM
    has anyone gotten prisma to work with supabase?
    👀 1
    a
    j
    • 3
    • 30
  • a

    Albert Gao

    06/13/2021, 9:55 AM
    can not use
    Prisma.validator()
    what am I missing here, the types are generated
    r
    • 2
    • 3
  • j

    Jay Cammarano

    06/13/2021, 3:45 PM
    Hello, I'm new to Prisma and have a question about many to many relation tables. I have two tables
    Releases
    and
    Artists
    that have a m-n relationship. I would just put and
    Artist[]
    column on releases and
    Releases[]
    on artists but I want to have the artist's role associated with the
    Release
    . So I made a table
    ArtistsOnReleases
    . It has columns:
    Copy code
    model ArtistsOnReleases {
      artist    Artist   @relation(fields: [artistId], references: [id])
      artistId  Int
      release   Release  @relation(fields: [releaseId], references: [id])
      releaseId Int
      role      Role     @default(MAIN)
      createdAt DateTime @default(now())
    
      @@id([artistId, releaseId])
    }
    I want to know how to seed it basically. RN I .create() my two artists and then for each artist I say:
    Copy code
    const artistOneJoin = prisma.artistsOnReleases.create({
          data: {
            artistId: 1,
            releaseId: 1,
            role: "REMIXER"
          }
        })
    but when I query for artistsOnReleases by artistID equals 1 I don't get anything returned. I figure this will apply to my mutations for releases as well so I want to get the seeding figured out.
    • 1
    • 2
  • m

    manuel

    06/13/2021, 6:30 PM
    Hey! I get this error when I want to run this migration... does anyone know how I can debug it?
    r
    • 2
    • 1
  • a

    André Nogueira

    06/13/2021, 6:54 PM
    I have 3 tables. (jobs, *jobQuestions*(that have jobId) and *jobAnswers*(that have jobQuestionId)). How can I createMany JobAnswers using a Job object through JobQuestions?
    r
    • 2
    • 1
  • m

    manuel

    06/13/2021, 7:39 PM
    I keep getting this error. When I run
    npx prisma db push
    my shema changes make it into the db. But if I want to run then
    npx prisma migrate dev --name whatevername
    I get the following error...
    r
    • 2
    • 20
  • o

    Omar Ghanim

    06/13/2021, 9:42 PM
    We have a problem with Prisma regarding the migration processes, it seems as if
    prisma migrate deploy
    command doesn't actually migrate the data in the production unless we run the
    prisma migrate dev
    first and generated the local migrations folder; Is this behavior normal? If not, what some other ways we can migrate the data at deployment without migrating in development the second problem , when we run command
    npx prisma migrate dev
    it gives the following errors (The database server at `<url>`:`5432` was reached but timed out. ) however we increase connection limit and pool , but when we run command
    npx prisma db push
    , schema changed and applied without any problem .
    👍 1
    r
    j
    • 3
    • 3
  • e

    Eric Martinez

    06/14/2021, 12:13 AM
    Hey guys, I probably know the answer, but can we write something like this with Prisma
    Copy code
    SELECT SUM(IF(COALESCE(nro_factura, -1) != -1, porc_hes, 0)) as sumaPctFacturado FROM ...
    I currently have the following with TypeORM and it works fine
    Copy code
    select([
        'SUM(porc_hes) as sumaPctPagado',
        'SUM(IF(COALESCE(nro_factura, -1) != -1, porc_hes, 0)) as sumaPctFacturado'
    ])
    r
    • 2
    • 1
  • k

    Kenneth Gitere

    06/14/2021, 4:32 AM
    I'd like to make a GraphQL API that uses Prisma for DB work. Would this just be a case of manually integrating my db code with an Apollo server or are there other approaches I can take up?
    r
    • 2
    • 2
  • u

    user

    06/14/2021, 7:01 AM
    Prisma Meetup #6 - Secure your Next.js + Prisma app with Auth0

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

    ◭ All the web applications that handle user-specific data, or certain levels of content access, need authentication and authorization. We can create our own authentication provider, but we also have third-party platforms created by security professionals. We can use these authentication services to avoid reinventing the wheel and rely on the expertise of security specialized companies. In this talk, you will see how to implement authentication in our Next.js applications using Auth0, an easy-to-implement authentication, and an authorization platform. Facundo is a Systems Engineer from Buenos Aires, Argentina, with 15+ years of experience in software development. Full Stack Developer. Auth0 Ambassador. GitKraken Ambassador. Cloudinary Media Developer Expert and a Prisma Ambassador. Facundo is also an open-source contributor. Learn more about Prisma: ◭ Website: https://www.prisma.io​​​ ◭ Docs: https://www.prisma.io/docs​​​ ◭ Quickstart: https://www.prisma.io/docs/getting-started/quickstart-typescript
  • u

    user

    06/14/2021, 7:01 AM
    Prisma Meetup #6 - Architecture of Distributed SQL

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

    ◭ Jim Walker is the VP of Product Marketing at Cockroach Labs. He is also a recovering developer turned product marketer and has spent his career in emerging tech. He believes product marketing is one of the most strategic functions in early-stage companies and helps organizations translate complex concepts into a compelling and effective core narrative and market strategy. Learn more about Prisma: ◭ Website: https://www.prisma.io​​​ ◭ Docs: https://www.prisma.io/docs​​​ ◭ Quickstart: https://www.prisma.io/docs/getting-started/quickstart-typescript
  • u

    user

    06/14/2021, 7:02 AM
    Prisma Meetup #6 - Writing and Building the Prisma Documentation

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

    ◭ Nilu and Martina take you on a tour of the Prisma documentation, including the website itself and what happens behind the writing desk. Martina writes documentation for developers and switches between dark and light mode at random in every app to keep things exciting. In previous careers she has been a front-end developer, a .NET developer, a consultant, and a build server goblin - and looks forward to the day when Database Cartoonist becomes an essential job. Nilufar Bava builds websites and apps and loves experimenting with new UI libraries. She moved to Berlin 5 years back and has been trying to learn the basics of the language since. Learn more about Prisma: ◭ Website: https://www.prisma.io​​​ ◭ Docs: https://www.prisma.io/docs​​​ ◭ Quickstart: https://www.prisma.io/docs/getting-started/quickstart-typescript
  • j

    jasci

    06/14/2021, 7:08 AM
    Hello everybody, can you please tell if it’s possible to remove the constraint for the number of clients? It’s for the testing.
    Error querying the database: db error: FATAL: sorry, too many clients already
    r
    j
    • 3
    • 45
  • j

    Jijin P

    06/14/2021, 7:37 AM
    I have been trying to get some campaigns from a table based on some conditions from the relation table.
    Copy code
    await prisma.campaigns.findMany({
            select:{
                url:true
            },
            where: {
                status:{
                    eq: 1
                },
                AND: {
                    {
                        // some conditions
                    },
                    {
                        // [BUG] relation based condition. 
                        OR: [
                            {
                                offer_devices: undefined
                            },
                            {
                                // condition based on offer devices.
                            }
                        ]
                    },
                }
            }
        })
    In this, if the offer_devices relation is null, then the condition is not working. I have tried to comment on the relation condition and it works. Looks like this condition has the issue.
    Copy code
    {
    	offer_devices: undefined
    }
    r
    • 2
    • 7
  • t

    Taylor

    06/14/2021, 8:18 AM
    Wondering if it's possible to import both Resolvers and types (code-first) instead of creating a prisma.schema file with MongoDB preview>
  • h

    Harun

    06/14/2021, 9:21 AM
    Hi guys, how can i use fixed prisma cli to generate schema?
  • h

    Harun

    06/14/2021, 9:22 AM
    I have an app that uses v. 2.10.2 I would like to keep using this version, how can i do so?
    r
    • 2
    • 3
  • j

    John

    06/14/2021, 10:23 AM
    I am thinking of a query and wondering if anyone has some ideas: I have a uuid(foreign key) and a number 1 to 5 I want to achieve the following: • If uuid + number exists => delete the entry • If uuid doesn’t exist => create new entry with number • If uuid exists with different number => update the record I guess the easiest way would be to just run a delete command (where uuid == $1) and always insert a new record or is there a better way ?
  • m

    Mykyta Machekhin

    06/14/2021, 10:44 AM
    Hello everyone. There is a need to add new attributes to the json field. The only way to update a field is to get it first, update it in the code, and then set it back? Or are there more customizable ways out of the box in prisma?
    r
    • 2
    • 7
  • s

    Sebastian

    06/14/2021, 1:27 PM
    Hello, I'm new to Prisma and have been trying to mock the Prisma client according to this guide: https://www.prisma.io/docs/guides/testing/unit-testing. I follow the singleton pattern and have a unit test for mocking the process of creating new data:
    Copy code
    import { prismaMock } from './../singleton';
    import { XyzLayerModel } from './../src/api/crud/xyz-layer/xyz-layer.model';
    
    test('Create new xyz-layer', async () => {
      const model = new XyzLayerModel()
      const newXyz = {
        id: 1,
        name: 'string',
        description: 'string'
      }
    
      prismaMock.xyzLayer.create.mockResolvedValue(newXyz);
      
      await expect(model.create(newXyz)).resolves.toEqual({
        id: 1,
        name: 'string',
        description: 'string'
      });
    });
    The following line is highlighted as an error by VSCode:
    prismaMock.xyzLayer.create.mockResolvedValue(newXyz);
    The error message says: Type of property 'AND' circularly references itself in mapped type '{ [K in keyof { AND?: Enumerable<XyzLayerScalarWhereWithAggregatesInput>; OR?: Enumerable<XyzLayerScalarWhereWithAggregatesInput>; ... 11 more ...; updatedAt?: string | ... 1 more ... | DateTimeWithAggregatesFilter; }]: Or<...> extends 1 ? { ...; }[K] extends infer TK ? GetHavingFields<...> : never : {} extends Fiel...'.ts(2615) The same applies to property 'NOT' and 'OR'. Does someone know a solution for this problem? Thank you in advance.
  • a

    AlexSPx

    06/14/2021, 4:17 PM
    Hello, I was wondering how can I do a many-to-many relationship between a User and a Team model. Basically I want to have a string array with the user ids in the Team schema.
    Copy code
    model User {
      id       String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
      email    String @unique
      username String @unique @db.VarChar(255)
      name     String
      password String
      teams Team[]
    
      @@map("user")
    }
    
    model Team {
      id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
      name String @unique
      displayName String
      description String @db.VarChar(500)
      membersId String[] @db.Uuid
      adminsID String[]
      members User[] @relation(fields: [membersId], references: [id])
    
      @@map("team")
    }
    I've tried a few other things to do it, but every time I get this error
    Key columns "membersId" and "id" are of incompatible types: uuid[] and uuid.
    Any help would be appreciated.
    j
    s
    j
    • 4
    • 24
  • m

    Michael

    06/14/2021, 5:45 PM
    Hi all, I have been running Prisma 2.19.0 for a while now without issue. And I just migrated from Prisma 2.19.0 -> 2.24.1 but now when I run:
    Copy code
    $> npx prisma generate
    Everything runs fine, but all the prior references in my code to any Models I had before are broken/missing. When I look in
    node_modules/.pnpm/@prisma/client@2.24.1_prisma@2.24.1/node_modules/@prisma/client/index.d.ts
    it's empty except for this one line:
    Copy code
    export * from '.prisma/client'
    To upgrade the dependency I ran:
    Copy code
    $> pnpm up prisma
    $> pnpm up @prisma/client
    j
    • 2
    • 41
1...443444445...637Latest