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

    Halvor

    06/16/2021, 3:48 PM
    i use express.
  • n

    Natalia

    06/16/2021, 4:01 PM
    🦕 Are there any Deno fans among us? Our friends from Meet.js Backend group organise a meetup tomorrow, where you can learn about Deno internals. More info here! 🦖
    🙌 1
    ❤️ 1
  • h

    Halvor

    06/16/2021, 4:16 PM
    Do i need to manually disconnect in order to use ts-node-dev
  • h

    Halvor

    06/16/2021, 4:18 PM
    Found this: https://github.com/wclr/ts-node-dev/issues/69
  • h

    Halvor

    06/16/2021, 4:18 PM
    But unclear why this is not working.
    r
    • 2
    • 1
  • f

    Filippo Sarzana

    06/16/2021, 5:50 PM
    Hi! I’m using Prisma with NestJS and GraphQL Federation 🎉 Everything is working perfectly when it comes to resolving external fields from GraphQL query. The issue I’m facing is when from a Federated Service I’m storing a new entity on the DB, that entity does not return external resolved fields. Assuming I have User and Post with 1-to-Many and I’m storing a new Post with authorId. A GraphQL query will return author with all computed fields but with an hypothetical ‘this.prisma.post.create(…)’ will not. It’s a complex issue I know, but maybe some of you already faced it. If you need more information I will provide them 🙏🏻
  • a

    Andrew Hollenbach

    06/16/2021, 9:43 PM
    Howdy! Running into an odd error specifically when upgrading from
    prisma
    2.23.0 -> 2.24.0. Has anyone encountered this? I can include more details if necessary. Note that this only happens when upgrading
    prisma
    and not
    @prisma/client
    , which is fine at 2.24+
    Copy code
    == Dockerfile
    <...>
    RUN yarn install
    RUN yarn run build:js
    RUN dotenv -e .env.development -- yarn prisma generate
    
    == Output
     > [10/10] RUN dotenv -e .env.development -- yarn prisma generate:
    #14 0.645 yarn run v1.22.5
    #14 0.705 $ /node_modules/.bin/prisma generate
    #14 1.355 Environment variables loaded from .env
    #14 2.070 Prisma schema loaded from prisma/schema.prisma
    #14 3.659 [1/4] Resolving packages...
    #14 4.129 [2/4] Fetching packages...
    #14 5.198 info fsevents@2.3.2: The platform "linux" is incompatible with this module.
    #14 5.198 info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
    #14 5.230 [3/4] Linking dependencies...
    #14 8.626 [4/4] Building fresh packages...
    #14 8.799 success Saved 0 new dependencies.
    #14 9.336 [1/4] Resolving packages...
    #14 9.845 [2/4] Fetching packages...
    #14 10.86 info fsevents@2.3.2: The platform "linux" is incompatible with this module.
    #14 10.86 info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
    #14 10.89 [3/4] Linking dependencies...
    #14 14.33 [4/4] Building fresh packages...
    #14 14.53 success Saved 0 new dependencies.
    #14 14.62 Error: Could not resolve @prisma/client despite the installation that we just tried.
    #14 14.62 Please try to install it by hand with npm install @prisma/client and rerun yarn prisma generate :pray:.
    #14 14.65 error Command failed with exit code 1.
    #14 14.65 info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
    m
    • 2
    • 3
  • t

    Tom

    06/17/2021, 5:49 AM
    Hi, I'm following this guide on unit testing: https://www.prisma.io/docs/guides/testing/unit-testing#singleton. If I run the example on my machine I get the jest warning:
    Jest did not exit one second after the test run has completed.
    I also thought that the singleton would kind of "mock" the database, but the user still gets created in the real database. What is wrong here? Edit: The warning doesn't show up if I call
    await prisma.$disconnect();
    r
    • 2
    • 1
  • t

    tim2

    06/17/2021, 7:12 AM
    Hey everyone, I’m excited to announce GraphCDN - The CDN for GraphQL APIs. I’ve worked on this the last couple of months together with @mxstbr Today, we’re on Producthunt and Hackernews - come and join the discussion!
    🚢 3
    💚 1
    👏 9
    fast parrot 5
    ❤️ 2
    graphql 5
    prisma rainbow 6
    👏🏾 1
    l
    n
    j
    • 4
    • 6
  • h

    Henri Kuper

    06/17/2021, 9:18 AM
    Hi, I wanted to filter all objects that did not have an optional relation or attribute set. Thereby I came across the
    is
    and
    isNot
    syntax. Is this documented somewhere? I couldn’t find it in the prisma docs. (Maybe I just missed it?) Thanks to the whole prisma team, for creating such a great productprisma rainbow
    r
    • 2
    • 5
  • b

    Benjamin Kroeger

    06/17/2021, 10:08 AM
    Am I correctly assuming that a relation scalar field can only be used in a single relation?
    r
    • 2
    • 1
  • d

    Dev__

    06/17/2021, 11:33 AM
    hello, i am trying to make a on to one self-relation but not working exactly as I want
    Copy code
    model Element {
        id        String   @id @db.VarChar(255)
        element   String   @db.VarChar(255)
        parentId  String?  @db.VarChar(255)
        required  Boolean  @db.Boolean
        createdAt DateTime @default(now()) @db.Timestamptz
        updatedAt DateTime @updatedAt @db.Timestamptz
    
        parent PoomElement? @relation("ParentElement", fields: [parentId], references: [id])
    }
    after I save the auto format of prisma adds another relation which I dont want
    Element Element[] @relation("ParentElement")
    is that above relation necassary? In the docs I see its not required: https://www.prisma.io/docs/concepts/components/prisma-schema/relations#one-to-one-self-relations
    r
    • 2
    • 1
  • a

    Alex Ruheni

    06/17/2021, 2:56 PM
    Tune in for What's new in Prisma (v2.25.0) in 4 minutes. prisma cool 👉🏾

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

    🙌 3
    prisma rainbow 3
    💚 3
  • e

    Edward Baer

    06/17/2021, 3:35 PM
    Is there a way to define a DateTime field in the schema.prisma, so that it creates the Database Date Time with the automatic update. ie: if the Database record is updated directly in the Database, or by another mechanism than Prisma ? I have this in the schema.prisma: created_at                    DateTime                @default(now())   updated_at                    DateTime                @updatedAt   deleted_at                    DateTime? It creates this in the migration:
    createdAt
     DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),     
    updatedAt
     DATETIME(3) NOT NULL,     
    deletedAt
     DATETIME(3), But I need this:
    createdAt
     DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),     
    updatedAt
     DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,     
    deletedAt
     DATETIME(3),
    j
    • 2
    • 21
  • m

    Michael

    06/17/2021, 4:50 PM
    With the new JSON filtering feature that's part of
    2.23.0
    - is there a way to cast the value of a "path"? For example our JSON in Postgres has string values for all paths - but we want to say convert that on the fly to a Postgres int to do <, <=, > ect comparisons? To solve this we are doing RAW prisma sql, but was wondering if there was features (or features in the future) that could address this.
    r
    • 2
    • 1
  • w

    Wilson

    06/18/2021, 12:53 AM
    Hello, running Prisma as an AWS lambda would mean the prisma ecosystem would restart every 15 minutes, right?
    r
    • 2
    • 1
  • i

    Ibrahim

    06/18/2021, 2:29 AM
    a trivial question here. is using Prisma & NextJS considered as monolith app ?
    j
    • 2
    • 1
  • k

    Keshav Ray

    06/18/2021, 4:40 AM
    Hi Everyone Hope you are having a good day. I am in process to start with prisma cloud and I needed some help I do not find any option where I can signup for it and do some hands on in free trial if there is any If this is not there can someone please suggest where I can start with
    r
    • 2
    • 2
  • a

    Albert Gao

    06/18/2021, 5:30 AM
    If I have multiple id, can I grab multiple items with these multiple id in one go? Thanks. Seems the findMany is slow
    r
    • 2
    • 2
  • s

    Sylvain (seel-vahn)

    06/18/2021, 5:39 AM
    I would see my Productivity increased if there was a way to quickly diff between two
    schema.prisma
    files locally (without having to run migrate commands) and directly output the result as SQL (such as:
    prisma diff schema1.prisma schema2.prisma --sql
    ). By any chance - any undocumented way to achieve this? Or is the migration engine tightly coupled to the database itself, as opposed to the schema files?
    👍 1
    r
    • 2
    • 4
  • d

    Danila Pavliuk

    06/18/2021, 6:04 AM
    Hey. I've read about pagination with prisma, but I have a question. I can't stand how to get number of posts for definition of number of pages. There's "count" method, but I can do this twice: once for "count" and once for "findMany". I suppose it's expensive and longer operations.
  • d

    Danila Pavliuk

    06/18/2021, 6:06 AM
    So, is there any way to determinate number of records in the database with "findMany" method?
    r
    • 2
    • 2
  • s

    Sylvain (seel-vahn)

    06/18/2021, 6:30 AM
    Another question related to many-to-many relations. I might need to convert an already existing implicit many-to-many relation, to an explicit m-n relation instead (to add extra fields in the relation table). In that context, I’d be interested to know if there is a recommended approach to smoothly achieve this with minimum disruption?
    r
    • 2
    • 4
  • m

    Mattias Ottosson

    06/18/2021, 8:22 AM
    Can someone point me in the right direction regarding including a enum column in a findMany query response? I have status column that i would like to include. Been fiddling around for a while but can’t really figure it out. 😔
    Copy code
    model Claim {
      id              Int       @id @default(autoincrement())
      customerName    String
      customerId      String
      contactPerson   String
      phone           String
      email           String
      orderId         String
      reference       String
      comment         String?
      createdAt       DateTime  @default(now())
      status          Status    @default(NEW)
      articles        Article[]
    }
    
    enum Status {
      NEW
      PROCESSING
      COMPLETED
    }
    
    await prisma.claim.findMany({
      include: {
        articles: true
      }
    });
    
    {
      id: 1,
      customerName: 'Name',
      customerId: 'Id',
      contactPerson: 'Person',
      phone: '049010000',
      email: '<mailto:email@mail.se|email@mail.se>',
      orderId: 'test123',
      reference: 'ref123',
      comment: 'Not bad',
      createdAt: 2021-06-17T18:26:36.529Z,
      articles: [ [Object] ]
    }
    r
    • 2
    • 12
  • m

    Manish

    06/18/2021, 1:09 PM
    I have a post model that contains a list of items. The Prisma relation is shown below.
    Copy code
    model Post {
      id        Int     @default(autoincrement()) @id
      title     String
      content   String?
      items     ItemsOnPosts[]
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
    }
    
    model Item {
      id     Int     @id @default(autoincrement())
      name   String
      posts  ItemsOnPosts[]
    }
    
    model ItemsOnPosts {
      post        Post     @relation(fields: [postId], references: [id])
      postId      Int      // relation scalar field (used in the `@relation` attribute above)
      item    Item @relation(fields: [itemId], references: [id])
      itemId  Int      // relation scalar field (used in the `@relation` attribute above)
      @@id([postId, itemId])
      notes   String?
      order   Int
    }
    The items within a post are ordered as per the
    order
    field in ItemsOnPosts. The problem arises when I want to add/ a new item in the the list, or want to change the order of items in a post. So, let’s say that a post (with id 1) has six items, with order as below.
    Copy code
    postId  itemId  order
    ------  ------  -----
    1       x       0 
    1       x       1
    1       x       2
    1       x       3
    1       x       4
    1       x       5
    2       x       0 
    2       x       1
    2       x       2
    2       x       3
    Two scenarios: - Add a new item to post 1 between 2 and 3. So this new item will become order number 3 and the order number of all items after will need to be incremented by 1. - Add a new item at the end. This would require me to get the order number of the last item in that post and then increment it by 1, i.e., 6. I know this is not a Prisma related problem. But I’m looking for the best way to maintain/update/handle these ordering of items in the post. Any insight/best practice is appreciated.
    r
    • 2
    • 9
  • n

    Nole Stock

    06/18/2021, 1:29 PM
    I have two tables. An
    Items
    table and a
    Sales
    . I want the
    Sales
    table to represent sold items but be able to have some different fields if the sale is on a different platform. I was thinking maybe just have different types of
    Sales
    tables but then
    Items
    would have a number of possible unused relations. I've used raw SQL before and designed some toy databases but never
    prisma.
    Does anyone have any advice on how to proceed? Here's my schema so far:
    Copy code
    model Item {
      id        Int      @id @default(autoincrement())
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
      name      String
      desc      String?
      quality   String?
      quantity  Int      @default(1)
      sale      Sale     @relation(fields: [saleId], references: [id])
      saleId    Int // relation scalar field (used in the `@relation` attribute above)
    
    }
    
    model Sale {
      id          Int      @id @default(autoincrement())
      createdAt   DateTime @default(now())
      updatedAt   DateTime @updatedAt
      boughtPrice Decimal
      item        Item?
      platform    String //Enum on postgress EBAY,MERCARI,ETC
    }
    r
    • 2
    • 6
  • d

    David Chalifoux

    06/18/2021, 6:40 PM
    I'm trying to do a nested write inside of an
    upsert
    , but Prisma is throwing an error whenever a related Model is referenced in the query ("Unknown arg"). The VSCode extension shows no error, so I am not sure why this wouldn't work. Any ideas?
    Untitled.js
    • 1
    • 1
  • i

    Ighor Martins

    06/18/2021, 6:50 PM
    Hey guys. I'm working on a project where I'm rewriting an existing website that has 7M monthly views (10m p/ day). I'm used to work with hasura, but this project needs a very custom backend, and each user visit needs to go to the database. So I need to think a bit about performance. When you query hasura through GraphQL, it normally compiles the entire query into a single SQL query to the database, and that's how it gets good performance. There is a lot of info on how prisma is slow on the internet, but I know a lot of them are from prisma 1. How different is prisma 2 performance wise? How does it compare with Hasura now? Knowing that I'll have to write the entire graphql server myself, it means that simply writing resolver for each entity will end up in a lot of queries to the database for just a single graphql query with nested resource, right?
    j
    • 2
    • 1
  • l

    Lars Ivar Igesund

    06/18/2021, 6:52 PM
    @Ighor Martins Assuming you most of your queries are read, you should check out the caching service presented yesterday - graphcdn.io
    t
    • 2
    • 2
  • i

    Ighor Martins

    06/18/2021, 6:55 PM
    @Lars Ivar Igesund Thanks for the answer. It's little to none the amount of cache I can leverage in this project. Assuming I can't leverage caching. I'm wondering about performance. But I'll check out the presentation. Thanks again.
1...445446447...637Latest