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

    Jacob Bohrtz

    10/24/2022, 8:44 PM
    Hopefully a simple question. In the following scenario, if project.ID is for some reason undefined, it will populate the sql with where 1 = 1 and update all columns. Is that intended behavior? It was a bug in the code that we had an undefined value but wouldn't expect to update all records in that scenario. Thanks!
    Copy code
    await mydata.oppProject.updateMany({
                where: {
                    ID: project.ID
                },
                data: {
                    ProjectNum: devnum
                }
            });
    translated to:
    UPDATE [dbo].[OppProject] SET [ProjectNum] = @P1 WHERE 1=1
    j
    • 2
    • 1
  • m

    Marcin Cebula

    10/25/2022, 8:26 AM
    When using Postgres with config:
    previewFeatures = ["referentialIntegrity"]  ... relationMode = "foreignKeys"
    should I be able to use
    NoAction
    ? The platform is throwing a P1012 with `Invalid referential action:
    NoAction
    . Allowed values: (
    Cascade
    ,
    Restrict
    ,
    SetNull
    ).` ...that or the platform is broken. I updated all the
    NoAction
    to something else and I see the Schema change in the SchemaViewer but the IDE is still throwing the same error with lines of code that no longer exist. ugh... 🙄
    ✅ 1
    r
    • 2
    • 3
  • n

    Nicola Genesin

    10/25/2022, 8:36 AM
    👋 !
    npx prisma db pull
    removes all virtual
    @relation
    fields. We're using planetscale and following your guide here https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/introspection-typescript-planetscale
    • 1
    • 1
  • d

    Danny SMc

    10/25/2022, 9:53 AM
    Hey all, I was looking into MongoDB and more about subdocuments, etc. I was wondering how does Prisma work with subdocuments (or embedded documents)? For example if I want to build a collection for all users, and then I want to then embed their vehicles into their users, how would this work with Prisma in a type-safe way? I have been using Prisma non-stop since I stumbled onto it, but would like to avoid using Mongo as a relational database and use it for it's main purpose. Any help/guidance/links would be highly appreciated. (I have not explored this personally before - so if the terminology is wrong - feel free to correct).
    ✅ 1
    r
    • 2
    • 4
  • p

    Perez cato Cato perez

    10/25/2022, 10:27 AM
    Hello please I need help understanding how to work with blobs in prisma. Do I give them a type string in the schema file or is there a special type for that
    👀 1
    j
    • 2
    • 12
  • n

    nick

    10/25/2022, 12:38 PM
    i see @db.Money referenced for SQL Server in the docs, but does it also work for PostgreSQL?
    ✅ 1
    r
    • 2
    • 3
  • f

    Federico

    10/25/2022, 1:10 PM
    Hey, I'm not sure this is the right place to ask such question, but I’d like to dynamically edit the object returned by a Prisma query like so:
    Copy code
    export const activities: QueryResolvers['activities'] = async () => {
      const activities = await db.activity.findMany({
        include: {
          author: true,
        },
      })
    
      activities.forEach((activity) => {
        activity.description = 'New description'
        activity.author.firstname = 'Rob'
      })
    
      return activities
    }
    This works fine with the first field, while it doesn’t seem to have any effect on the second one. Do you know if it possible to edit some fields of a nested object that was requested through an include? I don't know if this is relevant, but I use graphql to send the result back to the client. Thanks in advance!
    👀 2
    j
    • 2
    • 4
  • d

    David Hancu

    10/25/2022, 2:39 PM
    Another feature has been confirmed for Prisma Util v1.4.0, and that is the ability to remove middleware! PrismaClient will get an added method called
    $unuse
    , which will allow you to remove the middlewares that you've added previously.
    prisma rainbow 3
    👍 2
    👏 2
  • s

    Sebastian M.D.

    10/25/2022, 2:43 PM
    Sup in part 4 of: https://www.prisma.io/blog/fullstack-nextjs-graphql-prisma-4-1k1kc83x3v there seems to be an issue with the aws client. Already posted a question here: https://stackoverflow.com/questions/74193222/aws-fails-to-connect-to-s3-bucket?noredirect=1#comment130993622_74193222 Is the aws connector valid?
    👀 1
    v
    n
    • 3
    • 2
  • n

    nick

    10/25/2022, 6:02 PM
    quick Q: are “Interactive Transactions” (in preview mode) stable enough to use for simple transactions in production? i have some simple transactions that are awful to debug via Prisma nested writes, and wanna get the transaction guarantees PSQL gives me
    ✅ 1
    f
    • 2
    • 2
  • p

    Perry Raskin

    10/25/2022, 7:18 PM
    Hi! I’m trying to understand what’s necessary when it comes to connection pooling. I have a project that uses Supabase DB and connection pooling is enabled, but I’m not sure if I could (or should) utilize Prisma Data Proxy in addition. Any thoughts on this?
    👀 1
    n
    • 2
    • 1
  • a

    Amgelo563

    10/25/2022, 7:40 PM
    How do I do a "deleteIfExists" update nested query (https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#one-to-one-relations)? what I'm trying to do is using delete in case if it does exist and if it doesn't just do nothing; regular delete errors if the specified relation doesn't exist
    👀 1
    n
    • 2
    • 1
  • s

    Sebastian M.D.

    10/25/2022, 8:15 PM
    what package do you use to initialize a vanilla js repo (maybe with ts and eslint), that also has a git init (+ .gitignore) initialization step?
    ✅ 1
    n
    • 2
    • 4
  • d

    David Hancu

    10/25/2022, 8:23 PM
    Hi everyone! Prisma Util v1.4.0 is just around the corner, with another feature and 2 questions. The new feature is the added
    $schema
    field to all models, allowing you to get the DMMF data without having to use hacky ways. There's also another feature planned, which is quite massive: Data input validation at runtime (This feature will have a proposal created for it as it is quite big) Now for the important part, the 2 questions: • What does your testing workflow with Prisma look like and what improvements can be made to it? • Is there any feature that you're dying to see in Prisma but isn't on the roadmap? Thanks in advance!
    💬 1
    n
    • 2
    • 2
  • p

    Pat

    10/25/2022, 9:14 PM
    Hello, Postgres allows for functions in unique indexes, e.g.:
    Copy code
    CREATE UNIQUE INDEX lower_title_idx ON films(lower(title), author);
    It feels like there may not be a way to do this in prisma syntax... is that correct?
    Copy code
    @@unique([title, author])
    but, you know, with
    LOWER
    in there somehow. tia!
    👀 1
    r
    • 2
    • 4
  • m

    Michael Jay

    10/25/2022, 9:17 PM
    Question related to Filter on presense of related records There are two examples that are both from the
    User hasMany Posts
    relation. What about a
    hasOne
    ? I'm looking for all Widgets that DO have a Gizmo, where the relation is
    A Widget has zero or one Gizmo
    Doable? Would it be:
    Copy code
    await prisma.widget.findMany({
      where: {
        gizmo: {
          is: {},
        }
      }
    })
    👀 1
    n
    • 2
    • 3
  • n

    Nicola Genesin

    10/25/2022, 9:51 PM
    👋 !
    npx prisma db pull
    removes all virtual
    @relation
    fields. We're using planetscale and following your guide here https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/introspection-typescript-planetscale
    n
    • 2
    • 5
  • n

    Nathan Froese

    10/25/2022, 10:30 PM
    G’day Prisma team! My team is wanting to bump our Prisma client to the latest but we depend on nexus-prisma. Can we get the prisma dependency bumped to the latest please? cheers Updating the other dependencies within nexus-prisma would be also helpful thanks
    👀 1
    n
    • 2
    • 2
  • d

    David Hancu

    10/25/2022, 10:45 PM
    And just a small sneak-peek for Prisma Util v1.5.0, something many developers have wished for: Model creation at runtime. Stay tuned for this, as well as v1.4.0 which is dropping soon.
    👍 3
    prisma rainbow 2
    n
    • 2
    • 1
  • d

    DuckyDev

    10/26/2022, 6:45 AM
    Hi There, and thanks for the hard work with Prisma so far! I’m working with an existing database and I have used
    prisma introspect
    , however, whoever made the database is not consistent with table and column names, sometimes a
    space
    is used to separate words, another time
    _
    is used, and all columns are ALL CAPITAL LETTERS. Is there a way to let Prisma
    map
    this to something sane to work with overtime automatically so I don’t have to do that myself?
    👀 1
    n
    • 2
    • 7
  • a

    Akbar

    10/26/2022, 10:24 AM
    Hey everyone, I started getting this error after a field update on the schema. https://github.com/prisma/prisma/issues?q=RangeError%3A+Maximum+call+stack+size+exceeded+ Unfortunately, the solutions provided on the existing issues didn't work for me. I was hoping someone in here got a couple of minutes to point me in a direction to solve this 🙌
    Copy code
    TS: 4.8.4
    Prisma: 4.4.0
    Node: v16.15.0
    Thanks a bunch!
    👀 1
    r
    • 2
    • 4
  • s

    SKhan

    10/26/2022, 12:06 PM
    Hi, I am not sure whether this a db design issue or just an obscure scenario. Given the following:
    Copy code
    enum Type {
      ONEOFF
      FREQUENT
    }
    
    model A {
      type        Type?       @default(ONEOFF)
      b           B[]
      ...
    }
    
    model B {
      a            A?           @relation(fields: [aId], references: [id], onDelete: Cascade)
      aId          String?
      endDate      Date?
      ...
    }
    How would I create a query to get: • all data from
    model A
    where
    type === "FREQUENT"
    AND • only get data from
    model B
    where
    type === "ONEOFF"
    &
    endDate === null
    ? Will I have to create 2 queries for each scenario & then concat them?
    ✅ 1
    j
    • 2
    • 23
  • d

    Dan Calise

    10/26/2022, 2:27 PM
    So has anyone tried the new next 13
    app
    folder with Prisma? I’m not sure it will work as
    getServerSideProps
    and
    getStaticProps
    are no longer used. Seems like we’re forced to use
    fetch
  • l

    Lukas Vogel

    10/26/2022, 4:04 PM
    Hey everyone, new here
    👋 2
  • l

    Lukas Vogel

    10/26/2022, 4:06 PM
    i keep getting this error and am not finding anything about it online. Error: Could not find mapping for model product maybe someone here knows what it means?
  • l

    Lukas Vogel

    10/26/2022, 4:07 PM
    this is my model
    Copy code
    model product {
      id            Int     @id @default(autoincrement())
      stripeId      String
      artikelNr     String
      name          String
      active        String
      description   String?
      image         String?
      hersteller    String?
      category      String?
      subcategory   String?
      stripePriceId String
      price         Int
      currency      String
    }
    ✅ 1
    d
    • 2
    • 27
  • g

    Gezim

    10/26/2022, 4:24 PM
    Is Prisma Studio still maintained? There’s glaring issues (like not being able to Cmd+C to copy a column’s value).
    r
    • 2
    • 6
  • g

    Gezim

    10/26/2022, 4:24 PM
    Is this the appropriate channel for this?
    ✅ 1
    r
    • 2
    • 1
  • k

    Kay Khan

    10/26/2022, 6:03 PM
    Has anyone worked with prisma and multi schema database, can you describe what your experience is like?
    💬 1
  • j

    Jordan

    10/26/2022, 6:11 PM
    Hi all! Asking for some help here. Let's say I have a db that has a list of sessions with a unique userid. Additionally, each row can have a city that the session is in. How could I create a query using Prisma that returns a list of each user with all of their visited cities in one field?
    u
    • 2
    • 2
1...633634635636637Latest