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

    alexwasik

    06/28/2022, 6:50 PM
    I'm moving from SQLite to CockroachDB. In my
    schema.prisma
    I'm now getting this error
    ✅ 2
    a
    t
    • 3
    • 2
  • a

    alexwasik

    06/28/2022, 6:51 PM
    Error parsing attribute "default": The 'autoincrement()' default function is defined only on BigInt fields on CockroachDB. Use sequence() if you want an autoincrementing Int field.
    👀 2
  • a

    alexwasik

    06/28/2022, 6:52 PM
    The documentation shows
    autoincrement
    . Is this an error in the documentation?
  • d

    Danny SMc

    06/28/2022, 6:53 PM
    I am so confused, findMany does not work in prisma 4? :S has something broken? or am I being dumb?
  • d

    Danny SMc

    06/28/2022, 6:54 PM
    It was the latter, apologies, ignore me.
    😅 4
  • j

    James Johnson III

    06/28/2022, 7:00 PM
    Please reach out to me at your earliest convenience! Project details: Setting up Prisma API Proxy with the Unlimited Now Mobile PWA Current Goal: Creating a user session https://github.com/prisma/prisma/discussions/4575 My Prisma Setup: https://unlimitednow.me/index2 Thank you for your quick response James Leroy Johnson III
    v
    • 2
    • 2
  • a

    alexwasik

    06/28/2022, 7:26 PM
    Copy code
    npx prisma migrate dev --name init
    Environment variables loaded from .env
    Prisma schema loaded from prisma/schema.prisma
    Datasource "db": CockroachDB database "undefined", schema "public" at "localhost:26257"
    
    Error: P1000: Authentication failed against database server at `localhost`, the provided database credentials for `(not available)` are not valid.
    
    Please make sure to provide valid database credentials for the database server at `localhost`.
  • a

    alexwasik

    06/28/2022, 7:26 PM
    Where can I find documentation for this ☝️
    ✅ 1
    j
    n
    • 3
    • 17
  • a

    Adam

    06/28/2022, 7:49 PM
    Does Prisma have any way of running timed cron jobs, or scheduling jobs to be ran based on whats in the database?
    ✅ 1
    a
    • 2
    • 1
  • s

    Schalk Neethling

    06/28/2022, 9:54 PM
    Hey folks, if you have a moment: https://github.com/prisma/prisma/discussions/14041 - Setting IP address when running Prisma client locally
    ✅ 1
    v
    • 2
    • 2
  • p

    Pieter

    06/28/2022, 10:04 PM
    Is it just me or is the binary target I pinned it to the same as the one its looking for?
    👀 1
    j
    • 2
    • 1
  • a

    Amgelo563

    06/29/2022, 2:00 AM
    how should I go for writing a query for findMany where I want to find rows where one DateTime property is 30 days old (or older)? not sure if I should use something like
    gte
    or
    lte
    or what I should input there
    ✅ 1
    j
    n
    • 3
    • 11
  • c

    Chris Tsongas

    06/29/2022, 4:49 AM
    How do you handle creating migrations in different feature branches simultaneously? If I create a migration in one feature branch, then create another branch from main and try creating another migration, I get an error saying there are missing migration files and the database needs to be reset. Then things go downhill from there....
    ✅ 1
    f
    j
    • 3
    • 7
  • y

    yashvant

    06/29/2022, 11:41 AM
    Great to connect here, I want to filter name list as per Following criteria: 1. Name == Mahendra AND alive == true 2. Name== Mahendra AND infactedStatus==status AND alive == false I tried but didn't get expected results,
    👀 1
    a
    v
    • 3
    • 5
  • a

    alexwasik

    06/29/2022, 12:02 PM
    Switching to CockroachDB. After some work, I was able to run a migration but after the migration was created, I get this error.
    Copy code
    The following migration(s) have been created and applied from new schema changes:
    
    migrations/
      └─ 20220629115129_init/
        └─ migration.sql
    
    Your database is now in sync with your schema.
    
    Running generate... (Use --skip-generate to skip the generators)
    Error: Get DMMF: Schema parsing - Error while interacting with query-engine-node-api library
    Error code: P1012
    error: Datasource provider not known: "cockroachdb".
      -->  schema.prisma:6
       | 
     5 | datasource db {
     6 |   provider = "cockroachdb"
       | 
    
    Validation Error Count: 1
  • a

    alexwasik

    06/29/2022, 12:11 PM
    Copy code
    npx prisma generate
    Environment variables loaded from .env
    Prisma schema loaded from prisma/schema.prisma
    Error: Get DMMF: Schema parsing - Error while interacting with query-engine-node-api library
    Error code: P1012
    error: Datasource provider not known: "cockroachdb".
      -->  schema.prisma:6
       | 
     5 | datasource db {
     6 |   provider = "cockroachdb"
       | 
    
    Validation Error Count: 1
    
    Prisma CLI Version : 4.0.0
    😅 4
  • a

    alexwasik

    06/29/2022, 12:15 PM
    ☝️ _PRO TIP_: Make sure your
    @prisma/client
    is also
    4.0.0
    🤦
    ✅ 1
  • s

    Shahid Mawji

    06/29/2022, 2:15 PM
    Hey team, is there a way to reference a composite ID from another table?
    Copy code
    model ServiceMembership {
      service             Service    @relation(fields: [serviceId], references: [serviceId])
      serviceId           Int        @map("service_id")
      membership          Membership @relation(fields: [membershipId], references: [membershipId], onDelete: Cascade)
      membershipId        Int        @map("membership_id")
      assignedAt          DateTime   @default(now()) @map("assigned_at")
      prices              Price[]
    
      @@id([serviceId, membershipId])
      @@map(name: "service_membership")
    }
    I'd like to reference the ServiceMembership from the Price table. I can make it work by having a single referenced column in ServiceMembership but would prefer if I can use the existing composite ID (which it doesn't seem to support atm)
    Copy code
    model Price {
      priceId             Int               @id @default(autoincrement()) @map("price_id")
      serviceMembership   ServiceMembership @relation(fields: [serviceMembershipId], references: [serviceId, membershipId])
      serviceMembershipId Int               @map("service_membership_id")
    ✅ 1
    n
    • 2
    • 2
  • u

    יעקב

    06/29/2022, 4:47 PM
    Hi, I'm looking for ready to use docker-compose file with mongodb included and setup with single replica so I can use
    prisma db seed
    into the db
    👀 1
    a
    v
    • 3
    • 6
  • t

    Takeo Kusama

    06/29/2022, 6:00 PM
    Hi, is there way to reuse $rawQuery partial condition replace safely? ex)
    Copy code
    select
      ra.company_id as company_id,
      ra.user_id as user_id,
    from companies as cs
    join users as us  on cs.id = us.company_id
    where 
      user.score >= ${score}
      ${replacableCondition}
    ;
    In current, my codes have many similar sql scripts for sql injection protection like above except for writing raw query in ${replacableCondition} position.
    ✅ 1
    a
    • 2
    • 5
  • n

    nonissue

    06/29/2022, 10:12 PM
    I have questions/concerns about the
    @unique
    attribute (in my case, I'm using PostgreSQL). Basically, I understand how it works, but I think that the documentation/tutorials are in a way misleading, and could cause serious potential issues for a lot of users. The docs / tutorials frequently show examples were
    @unique
    is added to model fields as a constraint. This makes perfect sense for some most of Prisma's data types, but the thing that concerns me is when it is shown being used to enforce a unique constraint on
    String
    types, like emails and usernames. PostgreSQL uses deterministic collation by default, so filtering is case-sensitive by default. Yes, Prisma does offer case-insensitive filtering using
    mode
    , but I think a lot of people are going to set up their databases and not realize that, using just the
    @unique
    attribute, a user could sign up with
    <mailto:ceo@corp.com|ceo@corp.com>
    and another person could sign up with
    <mailto:CeO@corp.com|CeO@corp.com>
    , etc. I can't think of a single use case where you wouldn't want a string field for emails to be constrained in a case-sensitive way. Or a user could sign up with
    jack
    and another one could sign up with
    jaCk
    , etc. I understand that this is by design, and users can do things like enabling
    citext
    in PostgreSQL, or they could write client side logic to do a case-insensitive search for an existing user during sign up (This one in particular seems very brittle and not a very robust solution). The big issue to me is that the documentation doesn't seem to communicate that this very important implementational detail needs to be handled by the user themselves*. I'm not an expert with SQL or Prisma, so I'm fully aware I could be missing something, or I may have misunderstood how some of this works. Apologies in advance if that's the case. \: I'm fully aware that there are Prisma docs on case-sensitivity, case-insensitive filtering, and even ones that even mention
    citext
    , but I don't think they are easy to find, and they aren't referred to in many of the tutorials/examples/guides.*
    f
    v
    • 3
    • 3
  • d

    David Ilizarov

    06/30/2022, 1:37 AM
    Any updates on how soon we might be able to see typed Json fields in relational DBs like Postgres?
    ✅ 1
    a
    • 2
    • 1
  • d

    David Ilizarov

    06/30/2022, 1:38 AM
    https://github.com/prisma/prisma/issues/3219
  • o

    Ovidiu Bodea

    06/30/2022, 5:02 AM
    Hi guys, not sure if I should ask this on the general channel but I’ll give it a try since it seems like a lot of people are asking questions here I’m trying to dynamically call Prisma client by using a readonly array of models, but the client complains that the models don’t have compatible signature calls. Every value in the array is a model name, and all of the models have the same fields, but either way I’m just querying using a where clause on fields both models have
    Copy code
    const types = [
      'model1',
      'model2',
    ] as const;
    
    
    return client[field].findMany({
      where: {
        verified: true,
      },
    });
    The code works but TypeScript doesn’t like it
    Copy code
    error TS2349: This expression is not callable.
      Each member of the union type '(<T extends SkillTagFindManyArgs>(args?: SelectSubset<T, SkillTagFindManyArgs>) => CheckSelect<T, PrismaPromise<SkillTag[]>, PrismaPromise<...>>) | ... 4 more ... | (<T extends InterestFindManyArgs>(args?: SelectSubset<...>) => CheckSelect<...>)' has signatures, but none of those signatures are compatible with each other.
    Any ideas? Thank you
    ✅ 1
    a
    • 2
    • 1
  • k

    Kay Khan

    06/30/2022, 8:57 AM
    Has anyone noticed that the return type of a result is not "correct" when you use `select`/`include` e.g Here i want to find
    brands
    and join the
    image
    table on
    image_id
    .
    Copy code
    const options = {
      image: {
        select: {
          id: true,
          source: true,
          dtype: true,
         },
       },
    }
    
    const brands = await PrismaService.brand.findMany(options);
    brands
    has a return type of
    brand[]
    you can see it does not include the
    image
    relationship.
    Copy code
    export type brand = {
      id: string
      name: string | null
      image_id: string | null
      created_at: Date | null
      updated_at: Date | null
      deleted_at: Date | null
    }
    Therefore
    b.image
    throws a ts error
    Property 'image' does not exist on type 'brand'.
    Copy code
    brands.forEach((b) => console.log(b.image))
    👀 1
    r
    a
    • 3
    • 4
  • u

    user

    06/30/2022, 1:02 PM
    👉 How to upgrade to Prisma v4.0.0 --

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

    -- In this livestream, the Prisma team walks you through the process of upgrading Prisma to v4.0.0 and gives practical examples of the expected changes.
    🚀 4
  • d

    Dog

    06/30/2022, 1:38 PM
    Hi 👋 How do you guys go about storing "simple" analytics? For example, how much sales a product has or how many likes/dislikes a post has. You would ofc create a new db entry for a sale or like/dislike, but how do you guys go about showing that data? Do you guys keep the analytics on the model itself? (so having a likesTotal and dislikesTotal for example?) I know counting the amount every time the data has to be shown would be very inefficient, so what's a good approach?
    v
    • 2
    • 2
  • a

    alexwasik

    06/30/2022, 1:58 PM
    Query Question on Many to Many 🧵
    ✅ 1
    • 1
    • 7
  • m

    Moin Akhter

    06/30/2022, 1:59 PM
    Hello everyone i want to make a query.Let say i have a purchaseTable inwhich i have a purchasedPostId,buyerId and price.Now i want to make a query in such a way that i want to fetch all purchases with multiple information as shown in table.
    👀 1
    a
    v
    • 3
    • 4
  • a

    Amgelo563

    06/30/2022, 5:01 PM
    What could be causing
    Unique constraint failed on the constraint
    con a
    prisma.model.create({ someRow: { connect: id } })
    where a record with the specified id does indeed exist?
    nevermind, just me being stupid 😅
1...591592593...637Latest