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

    Kay Khan

    09/01/2021, 8:05 PM
    @Rodrigo Scomação do Nascimento I just read about this earlier, you can't https://github.com/prisma/prisma/issues/2377 There is a hacky alternative Create multiple files like this with your different datasource configuration
    Copy code
    prismaschemas/prod.schema.prisma
    prismaschemas/dev.schema.prisma
    package.json
    Copy code
    "scripts": {
      "prisma-prod": "mv prismaschemas/prod.schema.prisma ./schema.prisma 
      "prisma-dev": "mv prismaschemas/dev.schema.prisma ./schema.prisma 
      "prisma-refresh": "prisma db pull && prisma generate"
    }
    Then depending on your environment you can run either
    prisma-prod
    |
    prisma-dev
    then
    prisma-refresh
    . Modify prisma-refresh if you need to do migration.
  • k

    Kay Khan

    09/01/2021, 8:13 PM
    I'm probably going to use this method ^ to solve an issue i was having where views are not automatically pulled from the db using
    prisma db pull
    . So i will create a seperate
    views.schema.prisma
    file that contains my custom models (views). I should then be able to run
    prisma pull db
    and then merge
    views.schema.prisma
    then finally
    prisma generate
    to get the prisma client. Views not being supported is not great for us, without this hack the library is just unusable for me as views is pretty important for us.
    r
    • 2
    • 1
  • r

    Rodrigo Scomação do Nascimento

    09/01/2021, 10:03 PM
    @Kay Khan Thanks for clarifying, it's sad to hear that Prisma does not provide a way to do that, but I'll try that hacky way
  • r

    Rodrigo Scomação do Nascimento

    09/01/2021, 10:03 PM
    Tks
  • p

    Pieter

    09/02/2021, 12:32 AM
    https://github.com/prisma/prisma/issues/9073
  • t

    Tyler Clendenin

    09/02/2021, 3:10 AM
    I cannot figure out how to catch the Prisma
    NotFoundError
    thrown from the `findFirst`'s
    rejectOnNotFound
    option. the
    NotFoundError
    class/type doesn't seem to be exposed to be imported.
    r
    • 2
    • 5
  • j

    Jacob Simon

    09/02/2021, 3:40 AM
    Hi! I'm having some trouble creating mapped types from the model types Prisma exports
    Copy code
    type Map<T> = {
        [P in keyof T]: T[P]
    }
    type test3 = Map<PrismaModel>
    I would expect nullable properties to be nullable in the mapped result, but they're not. If I copy and paste the type definition into my types file and use the
    Map<T>
    type then the nullable properties remain nullable. Am I missing something here?
  • t

    Timo

    09/02/2021, 8:13 AM
    I want to
    findFirst
    an item and set a lock property immediately or with a following
    update
    transaction. What is the best way to do this?
  • t

    Timo

    09/02/2021, 8:14 AM
    Or is the chance something happening inbetween findFirst and update far too low?
  • t

    Timo

    09/02/2021, 8:16 AM
    Copy code
    const item = await prisma.item.findFirst({where: {isReady: true, isReserved: false}})
  • t

    Timo

    09/02/2021, 8:17 AM
    Copy code
    if(item) await prisma.item.update({where: {name: item.name}, data: {isReserved: true, lastReserve: moment.utc().toDate()}})
    r
    • 2
    • 2
  • k

    Kay Khan

    09/02/2021, 8:49 AM
    Hi friends im fairly new to graphql and prisma and working them together. Do people generally use code-first approach (TypeGraphQL) or sdl first? if you're using sdl-first is there a way to convert the models defined in schema.prisma to generate typedefs for gql?
    r
    • 2
    • 4
  • k

    Krishna Chaitanya

    09/02/2021, 9:25 AM
    Today I have received prismaday stickers. Thankyou prisma.
  • d

    Dev__

    09/02/2021, 10:04 AM
    is there a Prisma error that covers all possible exceptions. example
    Copy code
    catch(error) {
      if (error instanceof AnyPrismaError) {
        ...
      }
    }
    r
    • 2
    • 3
  • i

    Ippo

    09/02/2021, 10:10 AM
    can anyone tell me how prisma solves the n+1 problem? does it create a single (JOIN) statement for that or does it use dataloader?
    r
    • 2
    • 2
  • n

    Nditah Samweld

    09/02/2021, 1:04 PM
    Hi Everyone, I need help on a Prisma - Nest - Graphql. I encounter this error,
    Error: Cannot determine a GraphQL input type for the "company". Make sure your class is decorated with an appropriate decorator."
    I have gone through and through the project since yesterday and google it. Yet no clue. Thanks in advance @Dominic Hadfield
    d
    • 2
    • 15
  • n

    Naotho Machida

    09/02/2021, 2:07 PM
    Hi guys, good morning How I can solve this error?
    PrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: Attempted to serialize scalar 'null' with incompatible type 'String' for field condominioId.
    ✅ 1
    r
    • 2
    • 20
  • l

    Luis Haroldo Castro Cabrera

    09/02/2021, 2:21 PM
    how would you handle this scenario? i have a client table that can have several addresses, what should i do with the approach at the time of update, Scenario : if i remove an address from the array is the update capabilities of Prisma prepared for that one? is there any example i can check on something like that?
    r
    • 2
    • 9
  • m

    Max Torre Schau

    09/02/2021, 3:31 PM
    Hi everyone! Does anyone have experience with using multiple datasources within Prisma? We are using two separate databases with two different schemas, but are struggling to get it to work.
    r
    • 2
    • 6
  • h

    Harjaap Singh Makkar

    09/02/2021, 4:36 PM
    Hello! I'm trying to use Json filtering on my coordinates object which has { lat: XXX, lng: YYY } format but I'm getting the following error. Image of query attached (note, it's a conditional filter which only applies if bounds is not null)
    Copy code
    Object literal may only specify known properties, and 'path' does not exist in type 'JsonNullableFilter'.
    r
    • 2
    • 2
  • m

    Matt Langer

    09/02/2021, 6:50 PM
    hey everyone, a quick question about substring matching... imagine i have a user shaped like so,
    Copy code
    model User {
      id                             String                     @id @default(uuid())
      givenName                      String
      familyName                     String
    }
    if i want to perform a LIKE query against that table, it is quite simple to search for either the given name or the family name, but it is unclear to me how to use Prisma to search for a full name across both columns. in PostgreSQL i could do the following,
    Copy code
    WHERE (User.givenName || ' ' || User.familyName) LIKE ...
    is something like this possible with prisma?
    r
    • 2
    • 1
  • k

    Kay Khan

    09/02/2021, 7:47 PM
    Hi friends when using prisma + graphql is it possible to have the sql queries run concurrently to improve performance ? For example: Lets say you have a query that finds a person and you want to join in other relational tables (data1, data2, data3). I can see when i enable log, 4 seperate sql queries are being made here, seemingly one after the other?. is it possible to fetch this data from mysql concurrently?
    Copy code
    export const PersonResolvers = {
        Query: {
            person: Person,
        },
        Person: {
            data1: data1,
            data2: data2,
            data3: data3,
        },
    };
  • a

    Alan

    09/02/2021, 8:31 PM
    Is there a way to run
    prisma migrate resolve --applied "20201127134938_my_migration"
    but for All migrations? My prod database has 10 migrations. I just created a new environment with a fresh new database. I ran
    npx prisma db push
    . But the table
    _prisma_migrations
    is empty. So if I run
    npx prisma mograte
    it will drop an error as he will try to apply old migrations.
    • 1
    • 1
  • c

    Cleberson Saller

    09/02/2021, 9:04 PM
    Hi! I have a problem and I can't find any solution directly in Prisma: I have an implicit m-n relation and I need to cascade delete an entry from the User table to the Post table. I need that when a user is deleted, all posts are deleted together. Currently it only removes the entry from the relation table, but it doesn't actually remove the entry from the Posts table. Can anyone help me with this?
    r
    • 2
    • 1
  • j

    Jonas Rothmann

    09/03/2021, 1:01 AM
    I was hoping someone could help me solve why
    Copy code
    prisma.customer.findFirst({ where: { id: 11 }, include: { visits: { where: { status: "completed" } } } })
    returns customers with visits where status can be any string or even null?
    h
    r
    • 3
    • 13
  • j

    Jonas Rothmann

    09/03/2021, 1:13 AM
    Just to clarify I want only the ones where status is "completed"
  • s

    Saul Nachman

    09/03/2021, 6:19 AM
    Hi everyone. I'm having some trouble with the prisma client (I think) deploying to netlify with nextjs (with a supabase db). I'm able to write to the db but my queries are failings. Help understanding the debugging tools here would also be helpful. Where is the best place to get some help?
    r
    • 2
    • 37
  • v

    Vladi Stevanovic

    09/03/2021, 7:17 AM
    😍 Today's Prisma #DeveloperFavorite is Label-Sync by @matic! It enables us to have much a more efficient project management process where everything relies on a consistent set of labels. Triage, Prioritization, etc, everything can be done with labels! 👉 Check it out here: http://label-sync.com T Retweet here: https://twitter.com/prisma/status/1433689356527677440
    🙌 3
  • m

    Mykyta Machekhin

    09/03/2021, 9:58 AM
    Hi all. I need to insert a batch of 100 records into a table. Then refer to them. That is, at least get an array of inserted records identifiers. And as a maximum - the entire record. Is it possible to do this with the
    createMany
    , or I can do it by multiple call of
    create
    only?
    r
    • 2
    • 2
  • f

    Florian

    09/03/2021, 1:32 PM
    Hello 🙂 I'm finally trying out Prisma2, looks really nice so far 😄 I have a question about data modeling, I would like to have a model A referring to 0, 1 or 2 rows of model B, I tried something like this but with no success:
    Copy code
    model A {
      id String @id
    
      // A can exist without B
      mainB   B?      @relation(name: "AB", fields: [mainBID], references: [id])
      mainBID String?
    
      secondB   B?      @relation(name: "AB", fields: [secondBID], references: [id])
      secondBID String?
    }
    
    enum BType {
      MAIN
      SECOND
    }
    
    model B {
      id    String @id
      type  BType
    
      // B must be attached to an A to exist
      a   A       @relation(name: "AB", fields: [aID], references: [id])
      aID String
    
      @@unique([type, aID])
    }
    Am I forced to do a 1-m relation (ie. replace
    mainB
    and
    secondB
    with
    bs  B[]
    in
    model A
    ) or is it possible to achieve something like this? Even when I tried to add names to the relations it was still ambiguous for prisma :( Something I didn't try but I think would look terrible, is to completely separate the 1-1 relations (i'd like to refer to A from B without needing to check
    type
    to know which key to include in the query + I need to make sure B is linked to an A), ie.
    Copy code
    model A {
      id String @id
    
      mainB   B? @relation(name: "MainAB")
      secondB B? @relation(name: "SecondAB")
    }
    
    enum BType {
      MAIN
      SECOND
    }
    
    model B {
      id    String @id
      type  BType
    
      mainA   A?  @relation(name: "MainAB", fields: [mainAID], references: [id])
      mainAID String?
    
      secondA   A?  @relation(name: "SecondAB", fields: [secondAID], references: [id])
      secondAID String?
    }
    If you have any suggestion I'd be happy to hear ^^
    r
    • 2
    • 5
1...477478479...637Latest