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

    Victor Meireles

    01/02/2022, 6:09 PM
    Hello everyone. Someone have an code example of custom logger for NestJS? I'm trying, but only logs info and query: log: [ { emit: 'stdout', level: 'query' }, { emit: 'stdout', level: 'warn' }, { emit: 'stdout', level: 'error' }, { emit: 'stdout', level: 'info' }, ],
  • v

    Victor Meireles

    01/02/2022, 6:55 PM
    Somebody? I figured out that I need to throw the Prisma error inside my catche blocks to active the log, but I'm currently throwing the Nest Exceptions.
  • j

    Jonathan Gamble

    01/02/2022, 9:14 PM
    Does prisma cli use graphql caching like apollo or urql?
    m
    • 2
    • 1
  • e

    ezeikel

    01/02/2022, 10:52 PM
    Can anyone explain what an
    UncheckedCreate
    type is .e.g
    PaymentUncheckedCreateWithoutPeriodInput
    where
    Payment
    and
    Period
    are models in my schema?
    n
    • 2
    • 2
  • n

    Neo Lambada

    01/03/2022, 8:27 AM
    Copy code
    model User {
      id             Int            @id @default(autoincrement())
      createdAt      DateTime       @default(now()) @db.DateTime(0)
      updatedAt      DateTime       @default(now()) @db.DateTime(0)
      //relationships
      followedBy     FollowUser[]   @relation("follower")
      following      FollowUser[]   @relation("following")
    }
    
    model FollowUser {
      id          Int      @id @default(autoincrement())
      followerId  Int
      followingId Int
      createdAt   DateTime @default(now()) @db.DateTime(0)
      updatedAt   DateTime @default(now()) @db.DateTime(0)
      //relationships
      follower    User     @relation("follower", fields: [followerId], references: [id])
      following   User     @relation("following", fields: [followingId], references: [id])
    
      // @@id([followerId, followingId])
    }
  • n

    Neo Lambada

    01/03/2022, 8:28 AM
  • n

    Neo Lambada

    01/03/2022, 8:28 AM
    Copy code
    const user = await prisma.user.findMany({
              where: {
                id: 46,
              },
              include: {
                followers: true,
              },
              take: args.limit || undefined,
              skip: args.offset || undefined,
            })  This gives me the user with his followers as an array. can all the followers for a given user be retrieved?
    • 1
    • 1
  • m

    Maxence Lecanu

    01/03/2022, 9:16 AM
    Hello everyone, I have recently started to look into Hasura, and as much as I love the idea of having less to deal with graphql, I really appreciate the schema + migrations devX from Prisma and I would like to keep it in a setup involving Hasura (core, not hasura cloud). In the end, I would like to use Prisma as the ORM in my custom handlers, and define my database schema with this rather than the console. Per their documentation, it's possible, but I would like to have feedbacks from anyone actually using such a combination for real before moving forward with this. Has anyone some thoughts about it ? Especially, I have some questions • Is it possible to the extend that I want it to be ? • Is it okay, not to use the Hasura API in custom actions ? I feel like I am moving on to something considered a "bad practice" • In the end, was your migration to Hasura worth it ? Many thanks for your help, and happy new year !
  • a

    Arshath

    01/03/2022, 10:11 AM
    Hey Everyone, I need help creating Dockerfile for Nest.js, Prisma & PostgreSQL. I followed https://notiz.dev/blog/dockerizing-nestjs-with-prisma-and-postgresql, but it is throwing an error
    Prisma is not Initialized
    or Something. Anything am doing wrong?
    • 1
    • 5
  • i

    Ignace Mella

    01/03/2022, 11:40 AM
    Hi, is there a way to to execlude a field when pulling data. I like to hide the password
    n
    • 2
    • 1
  • u

    user

    01/03/2022, 1:28 PM
    🏢 Things that just make sense in our Prisma office in Berlin! #shorts

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

  • d

    Daniell

    01/03/2022, 2:51 PM
    https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-scalar-lists-arrays#filtering-scalar-lists There seems to be a typo in this preview description
  • e

    ezeikel

    01/03/2022, 10:15 PM
    Hey all! The docs make reference to Dependent writes and list Nested writes as the only technique to achieve this. I have a nested create within an
    .update()
    that needs to use the updated list of
    subscribers
    for example in the nested write to make a calculation. Is there any way to access the updated list of
    subscribers
    including the
    id
    of newly created subscribers for an update that hasn't finished executing yet?
    • 1
    • 1
  • r

    Robert Fish

    01/04/2022, 4:07 AM
    What is the common way to handle multiple repos using the same schema?
  • v

    Vilke

    01/04/2022, 6:51 AM
    Hey, I have problem with prisma getstaticprops in next.js: Reason:
    object
    ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types.
  • v

    Vilke

    01/04/2022, 6:53 AM
    after i JSON.stringify(data) the staticprops data and when I try to map it in jsx i get map is not function? stringify changes data back to string?
    a
    • 2
    • 1
  • v

    Vilke

    01/04/2022, 6:54 AM
    when I do {data} in jsx i get array with objects [{},{},{}...] in html
  • t

    Toru Eguchi

    01/04/2022, 10:19 AM
    Hi, I am wondering how to implement filtering with self reference tables. Let’s say you have User model which has Many to many self relations like below.
    Copy code
    model User {
      id         Int       @id @default(autoincrement())
      name       String?
      children   FamilyRelation[] @relation("child")
      parents    FamilyRelation[] @relation("parent")
    }
    
    model FamilyRelation {
      child    User @relation("child", fields: [childId], references: [id])
      childId  Int
      parent   User @relation("parent", fields: [parentId], references: [id])
      parentId Int
    
      @@id([parentId, childId])
    }
    Now I want to query users who has ancestors named “John”.
    Copy code
    user
    id | name   | parent_user_id | child_user_id
    1  | "John" | []             | [2, 4]
    2  | "A"    | [1]            | []
    3  | "B"    | [4]            | []
    4  | "C"    | [1]            | [4]
    5  | "D"    | []             | []
    
    → query result should be "A", "B", "C".
    c
    • 2
    • 4
  • a

    Astral Gaming

    01/04/2022, 1:32 PM
    Hi, I've got a question regarding the update operation. Is there a way to get the initial value of the row as an output from .update()? Or do I have to do a findFirst() to get that and then an update?
    m
    • 2
    • 1
  • d

    Daniel

    01/04/2022, 2:23 PM
    hi! related to this page https://www.prisma.io/docs/guides/performance-and-optimization/connection-management/configure-pg-bouncer does this also apply with statement mode instead of transaction mode? as per the pgbouncer docs:
    Copy code
    Statement Mode: Most aggressive method. This is transaction pooling with a twist: Multi-statement transactions are disallowed. This is meant to enforce "autocommit" mode on the client, mostly targeted at PL/Proxy.
    Wondering if you can use any of the two with prisma
  • d

    Demian N

    01/04/2022, 4:50 PM
    Hi all! Is there a way to use a graphql external API as a source of some PRISMA reolvers? I would like to merged in a central prisma server a custom DB and an external API from where I extract more data.
  • c

    Chris Tsongas

    01/04/2022, 5:57 PM
    Trying to deploy a large-ish Prisma & apollo-server-express application (~50 Prisma models) to Heroku, and deploying the application itself works, however when I try to run separate
    ts-node
    processes for cron jobs or seeding the database, the app crashes apparently running out of memory:
    Copy code
    <--- JS stacktrace --->
    
    FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
     1: 0xb00d90 node::Abort() [/app/.heroku/node/bin/node]
     2: 0xa1823b node::FatalError(char const*, char const*) [/app/.heroku/node/bin/node]
     3: 0xcedbce v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/app/.heroku/node/bin/node]
     4: 0xcedf47 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/app/.heroku/node/bin/node]
     5: 0xea6105  [/app/.heroku/node/bin/node]
     6: 0xea6be6  [/app/.heroku/node/bin/node]
     7: 0xeb4b1e  [/app/.heroku/node/bin/node]
     8: 0xeb5560 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/app/.heroku/node/bin/node]
     9: 0xeb84de v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/app/.heroku/node/bin/node]
    10: 0xe7990a v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/app/.heroku/node/bin/node]
    11: 0x11f2f06 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/app/.heroku/node/bin/node]
    12: 0x15e7819  [/app/.heroku/node/bin/node]
    Aborted
    error Command failed with exit code 134.
    I bumped up our Heroku dyno from 512MB of RAM to a Standard 2X with 1GB for $50/month, but still crashes. To get more RAM, I'd have to go with a Performance M dyno for $250/month, which is not affordable especially given I'll need three environments (test, staging, and production). Wondering if anyone else has run into this problem?
  • c

    Chris Tsongas

    01/04/2022, 8:22 PM
    I'm thinking it might be the TypeScript compile step that's running out of memory when trying to run
    ts-node
    since when deploying the server application that's working, TS gets compiled during the build step and the start command called by Heroku is just running
    node
    not
    ts-node
    .
  • s

    Shmuel

    01/04/2022, 8:23 PM
    Hi, The way to add join records to a many to many is like this...
    Copy code
    await prisma.role.update({
        where: { id: 1 },
        data: {
          users: {
            create: [
                { user: { connect: { id: 1 } } },
                { user: { connect: { id: 2 } } },
                { user: { connect: { id: 3 } } },
            ]
          }
        }
      })
    How would I remove records from a many to many? I can do it like this...
    Copy code
    await prisma.role.update({
          where: { id: 1 },
          data: {
            users: {
              deleteMany: [
               { user_id: 1 },
               { user_id: 2 },
               { user_id: 3 },
             ]
            }
          }
        })
    But is there a similar way of doing it like the first example just with 
    disconnect
    ?
    m
    • 2
    • 6
  • l

    Luke Morris

    01/04/2022, 9:38 PM
    Hi all - is there a way to create 4 entities in a nested write and connect them into a circular structure? e.g. A <- B is one-to-many A <- C is one-to-many B <-> C is many-to-many (with a join record)
  • l

    Luke Morris

    01/04/2022, 9:38 PM
    In one transaction, I'd like to Create one A Create one B, attached to A Create one C, attached to A Create one Join Record, connecting B and C
  • l

    Luke Morris

    01/04/2022, 9:44 PM
    I found https://github.com/prisma/prisma/discussions/6766
  • b

    buraks

    01/04/2022, 10:26 PM
    Hi all, has anyone tried enabling WAL on SQLite ? From what I have experienced if two separate process try to use the same SQLite with Prisma, they go through the lock hell. WAL seems to be solving that for SQLite with journal files. However, I am struggling to find a way to enable that with Prisma
  • f

    Franco Roura

    01/05/2022, 12:01 AM
    Hi team 👋 Does anyone know if the prisma client has some method to test if the current schema is valid? I'm using ECS to host my backend and the pipeline does
    primsa migrate deploy
    after the rollout of the pods. Before allowing users to consume the new pods of the API, ECS checks if these are healthy, in order to do that I usually define a simple endpoint at
    /api/health_check
    that returns 200 OK. Now, ideally the new pods shouldn't be considered "healthy" until their prisma client matches the deployed DB schema, is there a way to "health test" prisma inside my health check endpoint?
    n
    • 2
    • 2
  • u

    user

    01/05/2022, 8:00 AM
    Prisma Chats with Alex Ruheni

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

    In this video, Marketing Associate Intern Nika Music interviews Alex Ruheni, who is a Prisma Developer Advocate. The pair talk about Alex spending the summer with the Engineering team and pros and cons of DevRel and Engineering. Connect with Alex: Twitter: http://twitter.com/ruheni_alex Next: 👉 Next video: Prisma Chats w/ Nika Music

    https://youtu.be/3SEjbascuj0▾

    👉 Previous video: Prisma Chats w/ Carmen Berndt

    https://youtu.be/4mC03wvmKPY▾

    00:43- Intro 02:49 - Getting started w/ engineering 04:22 - Differences between university and company environments 05:13 - Biggest challenge 08:43 - Favorite part of working at Prisma 10:03 - Most exciting project 11:55 - Most exciting technology 14:42 - Preferred stack 16:40 - Advice for people entering tech world
1...529530531...637Latest