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

    Michael Dausmann

    08/08/2021, 7:17 AM
    what do folks do about reference data? like standard lists of things in tables etc.. do you just hack your migration.sql to add the necessary insert/updates or is there a better way to do it?
    r
    • 2
    • 1
  • p

    Patrick

    08/08/2021, 8:12 AM
    Hey folks, I have User model with nullable “name” How to query for Users that defined their names?
    Copy code
    const users = await prisma.users.findMany({
        where: {
          name: // not null
        }
      })
    r
    • 2
    • 7
  • h

    Halvor

    08/08/2021, 12:01 PM
    For @autoincrement(), can i select a starting value?
    o
    • 2
    • 3
  • a

    Aayush Rajvanshi

    08/08/2021, 4:14 PM
    Hey folks, what would be the right way to instantiate Prisma Client in NestJs while running in AWS Lambda? Please suggest.
    r
    • 2
    • 4
  • h

    Halvor

    08/08/2021, 6:19 PM
    I have a schema that looks like this:
    Copy code
    model User {
      id          Int       @id @default(autoincrement())
      createdAt   DateTime  @default(now())
      username    String    @unique
      password    String
      userUUID    UserUUID?
    }
    
    model UserUUID {
      id     String @id @default(uuid())
      user   User   @relation(fields: [userId], references: [id])
      userId Int    @unique
    }
    I want to add an entry to UserUUID if one is not present for the provided username, how can i achieve that? I tried with the following but it complains about not being able to uniquely identify a user.
    Copy code
    await prisma.userUUID.upsert({
            where: {
                user: {
                    username: username.toLowerCase()
                }
            },
            update: {},
            create: {
                user: {
                    connect: {
                        username: username.toLowerCase()
                    }
                }
            }            
        });
    Anyone knows how i can acheive this? Reason for having a UserUUID is that it should not always be present for every user, only users that have activated that feature.
    r
    • 2
    • 11
  • d

    Dev__

    08/08/2021, 7:10 PM
    is the
    transaction
    comparable with
    Promise.all()
    , if yes, does multiple prisma queries with with
    Promise.all()
    ?
    r
    h
    • 3
    • 5
  • c

    Caleb Clark

    08/08/2021, 8:59 PM
    Why is a model required to have an @id or @unique constraint?
    d
    • 2
    • 1
  • c

    Caleb Clark

    08/08/2021, 9:00 PM
    Shouldn't developer be able to choose whether they want such a constraint on their model?
    r
    • 2
    • 3
  • o

    Origin

    08/09/2021, 7:51 AM
    hi, can someone tell me where i can look up @db decorators? I'm trying to upgrade from 27 to 28, have mongodb and @db.array is no more
    r
    • 2
    • 12
  • m

    Mateusz Żmijewski

    08/09/2021, 10:15 AM
    Hey, what can I do about this error?
    r
    • 2
    • 2
  • p

    Paul

    08/09/2021, 12:32 PM
    Hey all. Is it possible to have where params like ? I'm looking at the docs and it seems I can only have 1 of AND, OR, NOT, etc and not more complex logic.
    Copy code
    {
      parentId: null,
      userId: 1234
      deletedAt: null,
      filterSize: {
        { filterSize: { lte: 199 }, },
        OR: { filterSize: { gte: 200 } }, { filterSize: { lte: 799 } },
        OR: { filterSize: { gte: 800 } }
      }
    }
    Docs: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#and Maybe something like:
    Copy code
    AND: {
       OR: [
          { filterSize: { lte: 199 }, },
          { filterSize: { gte: 200 } }, { filterSize: { lte: 799 } },
          { filterSize: { gte: 800 } }
       ]
    }
    r
    • 2
    • 2
  • a

    Alexei Snisarenko

    08/09/2021, 1:57 PM
    Just trying to get help from community.
  • d

    Daniel Sieradski

    08/09/2021, 6:22 PM
    hi, if i have a schema and a database login, how can i automatically generate a blank database from my table schema using prisma?
  • d

    Daniel Sieradski

    08/09/2021, 6:23 PM
    i tried doing an initial migration but it didn’t save anything
  • d

    Daniel Sieradski

    08/09/2021, 6:25 PM
    never mind think i got it
    r
    • 2
    • 3
  • t

    Tomas Jais

    08/09/2021, 7:57 PM
    Hello guys! I want to search through a DateTime for a specific date in Date format, in SQL I should do it with a between, how can I do it with the ORM?
    r
    • 2
    • 1
  • c

    Chip Clark

    08/09/2021, 8:24 PM
    Trying to filter on a subarray where both are true.
    Copy code
    License: {
                  some: {
                    AND: [
                      {
                        LicenseTypeID: 2
                      },
                      {
                        LicenseTypeID: 3
                      }
                    ]  
                  }
    There are records that meet the criteria, but this returns nothing. Any suggestions how to get the "some" to work with the AND?
    ✅ 1
    r
    • 2
    • 4
  • p

    Paul

    08/09/2021, 8:31 PM
    Hey is 2.29.0 tomorrow? Can someone pls confirm? Thanks
    r
    • 2
    • 2
  • d

    dhatGuy

    08/09/2021, 11:33 PM
    Can
    include
    return an object instead of an array of objects?
    r
    • 2
    • 2
  • p

    prisma chobo

    08/10/2021, 12:21 AM
    i get this warning….
    Copy code
    warn(prisma-client) Already 10 Prisma Clients are actively running.
    r
    • 2
    • 2
  • u

    user

    08/10/2021, 2:50 AM
    What's new in Prisma (v2.29.0)

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

    Daniel from the Prisma team discusses news in the Prisma ecosystem. Tune in to learn about new releases, planned features, and other interesting bits from the Prisma world. Learn more about Prisma: ◭ Website: https://www.prisma.io​​​​ ◭ Docs: https://www.prisma.io/docs​​​​ ◭ Quickstart:https://www.prisma.io/docs/getting-started/quickstart
  • h

    hayes

    08/10/2021, 4:13 AM
    Does the Prisma team have a relationship with the typescript team? I've got an issue that is probably more of a typescript performance issue than an actual Prisma issue. Trying to figure out if I should just open an issue in the TS repo, or if it would have more weight coming from someone working on Prisma.
    r
    j
    m
    • 4
    • 10
  • n

    Nditah Samweld

    08/10/2021, 8:18 AM
    Hello, I need more recent examples of Prisma, Nestjs, AppolloServer , GraphQL
    t
    • 2
    • 5
  • n

    Nathaniel Babalola

    08/10/2021, 8:57 AM
    hi please, I am trying to create a 1-to-1 relationship between two tables Traveler and Passport, and this is my schema.
    Copy code
    model Passport {
      passportId        Int      @id @default(autoincrement())
      passportNo        String
      nationality       String
      issuingCountry    String
      expiryDate        DateTime
      gender            String
      firstName         String
      lastName          String
      otherNames        String
      dateOfBirth       String
      isTravelCompanion Boolean?
      userId            Int? // relation scalar field  (used in the `@relation` attribute below)
      user              User?    @relation(fields: [userId], references: [id])
    
      //Passport relation
      traveller Traveller?
    
      @@map(name: "passport")
    }
    Copy code
    model Traveller {
      travellerId   Int          @id @default(autoincrement())
      title         String
      firstName     String
      lastName      String
      countryCode   String
      phoneNo       String
      address       String
      state         String
      country       String
      bookingRef    String
      travellerType String?      @default("adult")
      price         String
      currency      String
      isUser        Boolean      @default(false)
      userId        Int? // relation scalar field (used in the '@relation()` attribute below)
      user          User?        @relation(fields: [userId], references: [id])
      flightBooking FlighBooking @relation(fields: [bookingRef], references: [bookingRef])
    
      // passport relations
      passportId Int
      passport   Passport @relation(fields: [passportId], references: [passportId])
    
      @@map(name: "traveller")
    }
    but it shows this error when i run migrate,
    Error:
    :warning: We found changes that cannot be executed:
    `• Step 1 Added the required column
    passportId
    to the
    traveller
    table without a default value. There are 15 rows in this table, it is not possible to execute this step.` can someone please tell where I went wrong ?
    a
    p
    • 3
    • 7
  • s

    Slackbot

    08/10/2021, 9:23 AM
    This message was deleted.
    n
    p
    • 3
    • 2
  • o

    Origin

    08/10/2021, 9:39 AM
    Hi, can someone explain what the name does on @relation ? Is it a naming of the relation? Can it be anything, why is it even needed?
    r
    • 2
    • 3
  • p

    Paul

    08/10/2021, 10:23 AM
    I'm trying to simulate this query:
    Copy code
    select * from DamFile
    where deletedAt is null
    and (filterSize between 1 and 199 or filterSize between 200 and 799 or filterSize >= 800);
    With this JS Object:
    Copy code
    AND: [
       { OR: [{ AND: [{ filterSize: { gt: 0 } }, { filterSize: { lte: 199 } }] }] },
       { OR: [{ AND: [{ filterSize: { gte: 200 } }, { filterSize: { lte: 799 } }] }] },
       { OR: [{ filterSize: { gte: 800 } }] },
    ],
    Unfortunately I'm not getting any results. Am I able to do complex queries like this using nested conditionals? Thanks
    r
    • 2
    • 7
  • n

    Nathaniel Babalola

    08/10/2021, 11:24 AM
    Is it possible to pass in a single value to createMany and it'll still work ?
    r
    • 2
    • 2
  • g

    Gelo

    08/10/2021, 11:36 AM
    how to filter null property inside where?
    r
    h
    • 3
    • 15
  • n

    Nathaniel Babalola

    08/10/2021, 11:57 AM
    Copy code
    const id = req.user.id;
    
            const myBookings = await prisma.traveller.findMany({
                where: {
                    userId: id
                },
                select: {
                    flightBooking: true
                }
            });
    Hi pls I have this query, but there are multiple
    travellers
    that may have the same
    flightBooking
    , so it would return the same
    flightBooking
    details multiple times if different travellers have it. Is there a way I can optimize this query to return just one instance of
    flightBooking
    or not duplicate it if it has already returned it?
    r
    • 2
    • 2
1...468469470...637Latest