https://www.prisma.io/ logo
Join Slack
Powered by
# orm-help
  • 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
  • u

    夏の雪Official

    10/26/2022, 6:58 PM
    Hi, can I turn off autocreate db schema in my database? Because as I understand Prisma create table, but I don’t want this (I’ll create tables in my db).
  • m

    Marcus

    10/26/2022, 7:16 PM
    I’m following https://www.prisma.io/docs/guides/testing/unit-testing and struggling to get a successful test. Are there better tutorials?
    • 1
    • 1
  • s

    Sebastian M.D.

    10/26/2022, 9:30 PM
    when building part 4 of the tutorial of the fullstack prisma app (awesome-links) the following err is given:
    • 1
    • 2
  • j

    John Bradens

    10/27/2022, 1:08 AM
    Hi, I hope this is in the right place. I'm very new to all this. I want to show the name of the logged in user. I have this: `const ME_QUERY = gql``
    {
    me {
    id
    name
    }
    }
    ;
    and when I do
    const { data } = useQuery(ME_QUERY);
    console.log(data);
    I get undefined. Please let me know if you'd like me to share any more info
  • j

    John Bradens

    10/27/2022, 1:09 AM
    I'm trying to follow along with the prisma/apollo graphql tutorial, and trying to add thigns on my own to solidify the concepts in my brain
  • j

    John Bradens

    10/27/2022, 1:10 AM
    I also have this in query.js:
    function me(parent, args, context) {
    const id = getUserId(context);
    return context.prisma.user({ id });
    }
  • j

    John Bradens

    10/27/2022, 1:16 AM
    I guess a more simple question is how to even get the ME_QUERY working in the playground? If I log in with a user, and then in the playground I do
    query {
    me {
    id
    name
    }
    }
    , I get errors. How do I get it to show me the username that is logged in?
  • j

    John Bradens

    10/27/2022, 1:16 AM
    (thanks in advance)
  • j

    John Bradens

    10/27/2022, 2:58 AM
    Can anyone please help me understand the difference between these two functions? Why does one take context and one takes request? (Sorry if this isn't a prisma specific question - if I need to ask for help in a more appropriate place, please let me know & my apologies in advance):
    j
    • 2
    • 5
  • j

    John Bradens

    10/27/2022, 2:59 AM
    Copy code
    function getUserId(context) {
      const Authorization = context.request.get("Authorization");
      console.log("hello");
      console.log(context.request);
      if (Authorization) {
        const token = Authorization.replace("Bearer ", "");
        const { userId } = jwt.verify(token, process.env.APP_SECRET);
        return userId;
      }
    
      throw new AuthError();
    }
    
    class AuthError extends Error {
      constructor() {
        super("Not authorized");
      }
    }
    
    // function getUserId(req, authToken) {
    //   if (req) {
    //     const authHeader = req.headers.authorization;
    //     if (authHeader) {
    //       const token = authHeader.replace("Bearer ", "");
    //       if (!token) {
    //         throw new Error("No token found");
    //       }
    //       const { userId } = getTokenPayload(token);
    //       return userId;
    //     }
    //   } else if (authToken) {
    //     const { userId } = getTokenPayload(authToken);
    //     return userId;
    //   }
    
    //   throw new Error("Not authenticated");
    // }
  • c

    Cường Vũ

    10/27/2022, 3:29 AM
    Can anyone please help me, Is there a way to use
    db push
    without losing data ?
    👀 3
    j
    r
    • 3
    • 4
  • n

    Nik

    10/27/2022, 4:13 AM
    anyone know if this is valid prisma code? trying to filter based off two fields
  • n

    Nik

    10/27/2022, 4:13 AM
    ✅ 1
    j
    • 2
    • 22
  • n

    Nik

    10/27/2022, 4:45 AM
    I'm trying to find movies released between two dates, with the parameter being optional (that is return all movies if no dates are provided). Any clue what the error is from?
    j
    • 2
    • 1
  • n

    Nik

    10/27/2022, 4:46 AM
    ✅ 1
    j
    • 2
    • 8
  • d

    Divya Jain

    10/27/2022, 7:17 AM
    @here Anyone who has faced the issue using Prisma transactions?
    Copy code
    originalError": {
                "is_panic": false,
                "message": "Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'.",
                "meta": {
                    "error": "Transaction already closed: Transaction is no longer valid. Last state: 'Expired'."
                },
                "error_code": "P2028",
                "clientVersion": "3.15.2"
    },
    I have been facing this issue when there are multiple queries in a transaction. I tried to increased the timeout for some its working but for some its not I referred to this thread https://github.com/prisma/prisma/issues/13713. Then I even updated the Prisma version to 4.1.1 that also not helping that also referred from another thread If anyone has any insights on how to resolve it. Please do share.
  • m

    Mark

    10/27/2022, 7:41 AM
    Hi everybody, I’m wondering if anybody of you is strong enough with typescript to help me with a “dynamic service”. (Without typecasting to any). Basically what I want to get is to get the
    findMany
    with a
    Prisma.ModelName.
    But I get the following error:
    Each member of the union type has signatures
    Copy code
    const modelName = 'todoItem';
    
    return client[modelName].findMany(undefined);
    I have a playground here