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

    Arun Kumar

    06/09/2021, 7:49 AM
    @Daniel Laera How to access the stack trace?
  • a

    Arun Kumar

    06/09/2021, 7:50 AM
    The error is being sent as json response after the update statement but the update operations isn't occuring.
  • d

    Daniel Laera

    06/09/2021, 7:51 AM
    do you have more error details in your console? I suppose you’re in development mode like
    yarn dev
    …
  • a

    Arun Kumar

    06/09/2021, 7:51 AM
    No error details on the console
  • a

    Arun Kumar

    06/09/2021, 7:52 AM
    I tried to print the result of the update operation but it's not printing
    n
    d
    • 3
    • 19
  • y

    Yash Rathore

    06/09/2021, 7:57 AM
    Hello all, can anybody help me to model this entities. In UI I show some charts, all chart's sections background colors, tickColor,lineColor and all can be configured. I want these values default for all users, but still users able to update this.
    Copy code
    model ChartSection {
      id              Int     @id @default(autoincrement())
      backgroundColor String
      tickColor       String
      charts          Chart[]
    }
    model Chart {
      data ChartData[]
    }
    
    model ChartData {
      ...
    }
  • v

    Vladi Stevanovic

    06/09/2021, 8:02 AM
    👋 If anyone is looking for the Prisma(2) & MongoDB Early Access program here's the link: Pris.ly/mongo 🍃
    🍀 4
    prisma cool 1
    prisma rainbow 7
  • d

    Daniel Laera

    06/09/2021, 8:03 AM
    @Vladi Stevanovic I run
    👍 2
  • d

    Davedavedave

    06/09/2021, 8:27 AM
    Hey guys, I am trying to use the new "createMany" feature to seed my database, however I get a typescript error(vscode and phpstorm) that it doesnt exist
    Copy code
    const PriceService = await prisma.priceService.createMany({
        data: [ ... ],
        skipDuplicates: true,
      })
    "Property 'createMany' does not exist on type 'PriceServiceDelegate<RejectOnNotFound | RejectPerOperation>'." and its true, when i looked into the delegate, it has create, upsert etc, but createMany is missing. typescript version is 4.3 (editor uses correct one) Is this a library issue? Best regards, David
    d
    d
    • 3
    • 13
  • j

    Julian

    06/09/2021, 11:11 AM
    Hi, is there an easy/best-practice to convert this data structure to a create query where
    password
    is removed and replaced with
    hashedPassword
    , a nested
    profile
    is created and inside profile an
    address
    is created?
    Copy code
    {
      "email": "<mailto:test@test.nl|test@test.nl>",
      "password": "abcd",
      "profile": {
        "firstName": "Test",
        "lastName": "T",
        "address": {
          "street": "A",
          "zipcode": "B",
          "city": "C",
          "state": "D",
          "country": "E"
        }
      }
    }
    Because it seems like a bit of a pain to manually map every field to an object that can be used for a
    create
    query function
    r
    • 2
    • 9
  • j

    Julian

    06/09/2021, 11:55 AM
    Are there any performance benchmarks of Prisma versus other ORMs? Currently using TypeORM and SQLAlchemy in two other projects
    r
    • 2
    • 4
  • d

    Dev__

    06/09/2021, 12:51 PM
    how to set cascade
    SET NULL
    inside the schema.prisma? Is the only way of doing this an optional relation?
    r
    a
    d
    • 4
    • 28
  • e

    Eddy Nguyen

    06/09/2021, 1:02 PM
    Hello! Would we classify Prisma as schema-driven development 🙂 ?
    😉 1
    d
    j
    n
    • 4
    • 6
  • j

    Julian

    06/09/2021, 2:55 PM
    Hi, I am trying to abstract CRUD service to generic class and I found someone who did it, by using Delegates But when I try to pass
    Primsa.UserDelegate
    for my User model, it says it requires
    <_GlobalRejectSettings_>
    Where do I grab that from?
    r
    • 2
    • 2
  • j

    Julian

    06/09/2021, 2:56 PM
    Generic type 'UserDelegate<GlobalRejectSettings>' requires 1 type argument(s)
  • n

    nenadv

    06/09/2021, 3:39 PM
    Hello, all. How can this code
    Copy code
    if (!userId) {
      return;
    }
    let newUser;
    const checkIfNewUserMigration = await prismaClient.user.findFirst({
      where: {
        systemId: userId,
      },
      select: {
        systemId: true,
        id: true,
      },
    });
    if (!checkIfNewUserMigration) {
      newUser = await prismaClient.user.create({
        data: {
          systemId: userId,
          firstName: firstName,
          lastName: lastName,
          avatar: avatar,
          conversationMemberships: {
            create: {
              conversation: { connect: { id: conversation.id } },
            },
          },
        },
        select: {
          id: true,
          systemId: true,
        },
      });
    } else {
      newUser = checkIfNewUserMigration;
    }
    produce this error
    Copy code
    throw new import_engine_core.PrismaClientKnownRequestError(message, e.code, this.prisma._clientVersion, e.meta);
                    ^
    Error: 
    Invalid `prisma.user.create()` invocation:
    
    
      Unique constraint failed on the constraint: `systemId_unique`
    ? There are explicit checks in the code to avoid this as you can see. Can also provide schema etc. if needed? Also do add, on the sample batch data I'm testing this it randomly breaks, so it isn't specific data which causes the issues, sometimes it is the 100. entry, sometimes 130.
    s
    • 2
    • 10
  • m

    migz

    06/09/2021, 3:50 PM
    curious how would one go about performing a
    connectOrCreate
    on an array? similar to this, but instead creating the record if it doesn't exist
    Copy code
    data: {
        email: '<mailto:vlad@prisma.io|vlad@prisma.io>',
        posts: {
          connect: [{ id: 8 }, { id: 9 }, { id: 10 }],
        },
      },
    s
    • 2
    • 2
  • b

    Brandon Leichty

    06/09/2021, 4:46 PM
    Hey all! I'm working on a side project for keeping track of favorite quotes. I've got a question around updating a field using Prisma. I'm wanting to make sure that
    userId
    of the currently logged in user matches the
    quoteId
    that the user is looking to update/delete. This is what I'm currently doing (and it works). But I'm wondering if there's a way I can do this without multiple calls to the database? Would be great if I could do something like
    prisma.update({ where: {id AND userId}})
    👈 pseudocode.
    Copy code
    editQuote: async (_, { ...input }, context) => {
          const { prisma, user } = context;
          const { id, quote, author, categories, favorite } = input;
    
          const originalQuote = await prisma.quote.findUnique({
            where: { id },
          });
    
          // Check to see if the logged in user owns this quote before updating
          if (user == originalQuote.userId) {
            const editedQuote = await prisma.quote
              .update({
                where: {
                  id: id,
                },
                data: {
                  quote,
                  author,
                },
              })
              .catch((e) => {
                throw e;
              });
            return editedQuote;
          } else {
            console.log("You are not authorized to edit this quote");
            return null;
          }
        },
    s
    a
    • 3
    • 4
  • j

    Juan Varela

    06/09/2021, 5:31 PM
    Hi all! In graphql-shield it states:
    To return custom error messages to your client, you can return error instead of throwing it.
    The problem is that when using nexus.js with typescript, the resolver doesn’t allow to return an error. Other than returning:
    return new Error("Custom error") as any
    What can I do if I have something like this:
    Copy code
    export default mutationField('signup', {
      type: AuthPayload, // Here should be OR ERROR
      async resolve(_parent, args, context: Context) {
    Thank you very much in advance!
  • j

    jasci

    06/09/2021, 6:54 PM
    Hello, everybody. Wanted to ask about fields’ resolution with prisma client. Here is 2 queries: 1.
    Copy code
    context.prisma.someModel.findUnique({ where: { id: someId } }).someField()
    2.
    Copy code
    (await context.prisma.someModel.findUnique({ where: { id: someId } })).someField
    When I use
    await
    it seems like I don’t get access to the relation fields. In the second example if the field is virtual(some relation) it won’t be available, why is that ? But if I use the example #1 I am able to somehow call the field and resolve its value. How does it work ? How to properly retrieve fields of a particular model ? Maybe some links to the doc? Thank you.
    s
    r
    • 3
    • 6
  • d

    David

    06/09/2021, 7:07 PM
    Hey Folks! Prisma seems really great, I'm curious though, does Prisma have any way to cache queries in some faster store such as Redis? Couldn't find anything on GH and it didn't seem like Prisma middleware were meant for this.
    j
    r
    • 3
    • 8
  • b

    brettski

    06/09/2021, 8:26 PM
    Where is the change log maintained?
    j
    • 2
    • 3
  • h

    Halvor

    06/09/2021, 8:43 PM
    i need to create a row in a main table, and then multiple others in other tables that have a relation with the main table, how to achive this with prisma?
  • h

    Halvor

    06/09/2021, 8:46 PM
    i also have a json object representing some of the rows, how can i use that and a t the same time add the remaining ones.
    r
    • 2
    • 1
  • h

    Halvor

    06/09/2021, 8:46 PM
    ?
  • b

    brettski

    06/09/2021, 9:29 PM
    Node (14.16.0) app package.json dependency has both
    @prisma/client
    and
    prisma
    Installation is done using
    npm i --production
    version
    2.22.1
    seems okay when I try
    2.24.1
    I aways end up with
    Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
    rolling back to
    2.22.1
    and all is okay again. No other changes. Is there anything in versions > 2.22.1 which may be causing this in this scenario? I looked through the release notes and nothing stuck out.
    r
    • 2
    • 3
  • a

    Albert Gao

    06/10/2021, 3:08 AM
    hello, what is the correct prisma type to save a data like this image? this is a stock price data,
    open
    high
    low
    are prices,
    volume
    are big numbers (BigInt?) I am using PostgreSQL 🙂 i can save as all string and parse at run time, but just want to have more precise data type so maybe i need to query the price in the future, just in case Thanks
    • 1
    • 1
  • k

    Kent C. Dodds

    06/10/2021, 3:13 AM
    Heya friends. Quick question. Nevermind. The Prisma magical TypeScript just answered my question. Y'all are magicians. Thank you.
    prisma rainbow 5
    a
    • 2
    • 4
  • s

    Samrith Shankar

    06/10/2021, 5:27 AM
    Hey, is there a timeline on Undici v4 or some alternative which will resolve the http_common not found errors? I can’t migrate to newer versions of Prisma as I am facing this issue
    r
    a
    • 3
    • 3
  • e

    EGOIST

    06/10/2021, 6:28 AM
    Hi, I built this: https://github.com/egoist/prisma-repl but I think it could be built directly into Prisma CLI instead. 😙
    💯 4
    j
    • 2
    • 6
1...441442443...637Latest