https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# prisma-client
  • d

    Dan M

    04/02/2022, 7:54 PM
    Just playing with Interactive Transactions preview today and noticed a missing type shortcut that's really needed:
    Copy code
    export type PrismaTransactionClient = Omit<PrismaClient, '$connect' | '$disconnect' | '$on' | '$transaction' | '$use'>;
    Can this be added to the client generator?
    n
    • 2
    • 1
  • d

    Dan M

    04/02/2022, 7:56 PM
    Looks like there's an issue for this: https://github.com/prisma/prisma/issues/12436
    👍 1
  • a

    Arthur Cachero

    04/06/2022, 6:12 AM
    Hi! I'm running a NEXTjs with Prisma/Postgres db Wondering if someone can take a look at this gist to help me out. I'm having trouble with me model relations. https://gist.github.com/sebass-surfer/3a300a0d50abdcdad9bffbe9a05084c2
    a
    • 2
    • 2
  • a

    amock666

    04/07/2022, 4:24 PM
    Hi guys! How do I remove the square brackets in there? I want it to look like a json object.
    a
    • 2
    • 7
  • f

    Freeman Jiang

    04/09/2022, 9:30 PM
    Hi! Is there a way to disconnect multiple records (but not all)? Been looking through the docs and
    updateMany
    seems like the closest thing, but it’s only letting me update scalar fields
    n
    • 2
    • 1
  • a

    amock666

    04/11/2022, 4:43 AM
    Hey guys queryraw doesn't work for me, data appear on prisma studio and there is no problem but when I try to run the query: const users = await prisma.$queryRaw`SELECT * FROM User`; , It only shows my postgres username. When I check my data on psql, It shows the same, tables appear but there is no data inside.
    n
    • 2
    • 1
  • d

    David Marr

    04/11/2022, 1:40 PM
    I'm trying to follow the examples to perform an upsert operation with a nested
    connectOrCreate
    call. The error I'm getting is saying that the
    author
    arg is unknown. Specifically:
    Unknown arg
    author
    in create.author for type TweetUncheckedCreateInput. Did you mean
    authorId
    ? Available args:
    type TweetUncheckedCreateInput {
    id: String
    authorId: String
    createdAt: DateTime
    entities?: Json | Null
    media?: MediaUncheckedCreateNestedManyWithoutTweetsInput
    mediaKeys?: TweetCreatemediaKeysInput | List<String>
    publicMetrics: Json
    text: String
    type?: String | Null
    }
    The relevant client code is here: https://gist.github.com/marr/c574e7a854223e828e652753d08dd117#file-twitter-ts-L42 and relevant schema is here: https://gist.github.com/marr/0b2e6a58858388df6b448f5d1d2dd879#file-schema-prisma-L23 Can anyone help me troubleshoot this?
    n
    • 2
    • 1
  • d

    David Marr

    04/11/2022, 2:52 PM
    Would the nested models be an issue on mongo or something? I'm thinking I just remove the relations and manually query with an aggregation pipeline
    n
    • 2
    • 1
  • m

    Mischa

    04/11/2022, 6:12 PM
    Do you use Prisma with AWS CDK? Have you wanted a really amazing prisma lambda layer with just the minimum needed to run prisma and the proper node
    externalModules
    settings? Look no further! This was developed over many days of grueling testing and trial and error. I hope to spare others the same headache.
    Untitled.ts
    🙌 2
    👀 2
  • d

    David Marr

    04/11/2022, 7:29 PM
    Would a column named
    type
    cause problems?
    n
    • 2
    • 5
  • d

    David Marr

    04/15/2022, 3:13 PM
    How would I receive a string from my datetime column queries?
  • d

    David Marr

    04/17/2022, 1:18 AM
    I'm trying to iterate over a result, but getting an error:
    Type 'JsonObject' must have a '[Symbol.iterator]()' method that returns an iterator
    Code in question (mongodb):
    const res = await db.tweet.aggregateRaw({
    pipeline
    });
    for (const tweet of res);
    a
    • 2
    • 1
  • d

    Demian N

    04/18/2022, 3:49 AM
    Is there any substantial difference in using
    connect
    or not when creating a row with a foreign key field? I note the result is the same but what would I choose one over the another one? Or this just for a declarative/semantical reason? Example:
    Copy code
    model User {
      id            String    @id @default(cuid())
      name          String?
      email         String?   @unique
      emailVerified DateTime?
      image         String?
      accounts      Account[]
      sessions      Session[]
      rooms         Room[]
    }
    
    
    model Room {
      id          Int    @id @default(autoincrement())
      userId      String
      title       String
      description String @db.Text
      user        User   @relation(fields: [userId], references: [id])
    
      @@unique([userId, title])
    }
    From the above schema, If I would like to add a new room I could do: Let's say
    user
    hs already being resolved to a user found in the User model
    Copy code
    prisma.room.create({  data: { title, description, user: { connect: { id: user!.id } } }})
    or also,
    Copy code
    prisma.room.create({  data: { title, description, userId: user!.id }} )
    What is the correct way?
    n
    • 2
    • 1
  • j

    Jason

    04/18/2022, 7:47 AM
    If I run SELECT ... FOR UPDATE inside an interactive transaction, when is the row actually locked? Is it when that line of code runs, or is it when the transaction is committed?
    n
    • 2
    • 3
  • f

    Filip Woźniczak

    04/19/2022, 11:11 AM
    Is it possible to create a field that is unique and can be optional ? Like in the example?
    Copy code
    phone        String?       @unique
    n
    • 2
    • 2
  • f

    Filip Woźniczak

    04/19/2022, 11:11 AM
    For MongoDB
  • r

    Rintsi

    04/19/2022, 4:49 PM
    Not sure how many times this has been asked before, but is there a preferred way of accessing custom claim from an access token inside a @Query()? I have a custom claim that has an array if strings I'd like to use in a query
    where: { id: { in: identifiers } }
    There is so much inception going on that I have hard time keeping up... Express -> NestJS -> Prisma
    n
    • 2
    • 5
  • j

    Jeet Mehta

    04/24/2022, 10:03 PM
    👋 Hey folks. Quick Typescript question - how do I access nested fields when using the auto-generated Typescript interfaces from Prisma Client? For example, the model
    User
    contains a 1-many link to
    Services
    . We import the
    User
    interface but it only has
    serviceId
    , so in our code
    user.service
    is generating a typescript error (even though the object is present in the data returned from the DB). Sometimes we access objects several levels deep (i.e.
    user.service.booking
    ), just wondering if there's a recommended approach for this.
    n
    • 2
    • 2
  • m

    Mischa

    04/25/2022, 11:19 AM
    Invalid
    prisma.queryRaw()
    invocation: Your raw query had an incorrect number of parameters. Expected:
    0
    , actual:
    1
    . What am I doing wrong here?
    Untitled.ts
    • 1
    • 2
  • p

    Pinja Jäkkö

    04/25/2022, 1:32 PM
    I'm trying to filter by null values, but am getting the following error:
    Type '"AnyNull"' is not assignable to type 'JsonNullableFilter | undefined'.
    My client configuration looks like this:
    generator client {
    provider        = "prisma-client-js"
    previewFeatures = ["filterJson", "interactiveTransactions"]
    }
    I have a postgresql database, my prisma client version is 3.5.0, and the field I am trying to filter by is an optional JSON field. the findMany call:
    await prisma.chart.findMany({
    where: {
    oldState: Prisma.AnyNull
    },
    });
    a
    • 2
    • 3
  • n

    Navin

    04/26/2022, 5:10 AM
    What’s the best way or suggested approach to map prisma data models to graphql types? I’m considering having pure functions acting as mappers that are testable, but first curious if there is something that I can already use. Thanks in advance
    m
    • 2
    • 2
  • a

    Alex Valle

    04/27/2022, 11:22 PM
    Hello everyone! I am having a problem, I have a dockerized application and I get the following error:
    ✅ 1
    n
    • 2
    • 8
  • m

    Mischa

    04/29/2022, 8:31 AM
    I'm using lambda and I got this error
    FATAL: sorry, too many clients already
    I have
    connection_limit=5
    on my
    DATABASE_URL
    Any idea what to do about this specific error? I think it means too many connections for the specific client?
    n
    • 2
    • 4
  • a

    Andrew Hammond

    04/29/2022, 4:02 PM
    Can anybody explain or point me to documentation regarding unchecked vs regular input args?
    a
    • 2
    • 2
  • n

    Navin

    05/01/2022, 4:41 PM
    Is there a way to configure prisma to create date columns (createdOn, updatedOn) on models defined in the schema without having to explicitly create them?
    s
    • 2
    • 3
  • a

    Alex Valle

    05/02/2022, 10:59 PM
    Hello everyone! How do you do the prism generate inside your Dockerfile? I do it with
    RUN npx prism generate
    but it makes my image too big.
    n
    • 2
    • 1
  • j

    James L

    05/02/2022, 11:47 PM
    Hey all, I'm trying to query a Postgres JSONB field (and avoiding using raw) with the js client. Filtering by an array's object isn't supported w/ the Postgres connector yet - only MySQL as of right now. Performance isn't really a huge deal for me since the query is run once per day and isn't user-facing, but does anyone know if there's a (sane) way to use Prisma to return values from the JSONB column defined below where
    name
    is equal to
    foo
    ? My current hack in raw SQL for when I don't feel like parsing and filtering like an adult is a shameful display of hubris with
    items::TEXT ~ 'foo'
    lol. Data shape in the "items" column:
    Copy code
    [
      {
        "name": "foo",
        "value": "example_1"
      },
      {
        "name": "bar",
        "value": "example_2"
      },
    ]
    n
    • 2
    • 2
  • b

    Ben Ezard

    05/03/2022, 9:39 AM
    I'm currently using
    prisma.$on('query', event => {});
    to log queries, but I'd like to be able to associate these queries with a particular HTTP request In the rest of my codebase, I have a unique "request ID" that I can pass around, so that any logs from the same request can be associated with each other Is there a way for me to achieve this with regards to logging what Prisma is doing please?
    o
    • 2
    • 2
  • j

    James L

    05/03/2022, 10:22 AM
    I just took a look because I was curious, too. The generated code is pretty strict about what you can pass w/ your query config.. I have a hacky idea if you want to try that lol
  • j

    James L

    05/03/2022, 10:23 AM
    you can add a debug string to all of your models and write a custom middleware to remove it from the params (where, data, etc) before sending it to the db
1...181920...23Latest