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

    Tarik Brat

    07/13/2021, 11:38 AM
    Hello guys, quick question ? How can I select custom fields with prisma not only existing ones? For instance I want to get average between X and Y columns and make custom column with that value.
    m
    • 2
    • 3
  • a

    Arun Kumar

    07/13/2021, 11:52 AM
    I'm facing this error when trying to run
    prisma migrate div
    Copy code
    Context: Timed out trying to acquire a postgres advisory lock (SELECT pg_advisory_lock(72707369)). Elapsed: 10000ms. See 
    <https://pris.ly/d/migrate-advisory-locking> for details.
    n
    • 2
    • 5
  • h

    Henri Kuper

    07/13/2021, 2:03 PM
    I update prisma from 2.20 to 2.26 (and then also to 2.27) If I run
    yarn prisma generate
    I get the following error:
    Copy code
    Prisma schema loaded from prisma/schema.prisma
    npm ERR! code E401
    npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/henri/.npm/_logs/2021-07-13T13_55_51_322Z-debug.log
    Error: Command failed with exit code 1: npm install -D prisma@2.27.0
    I does not seem like a pure prisma issue, but maybe anyone has an idea what this could be caused by? If needed I can add the debug.log messages
    r
    • 2
    • 7
  • a

    Amit

    07/13/2021, 2:07 PM
    Hey, since 2.26.0 I cannot create a prisma client by using
    nApi
    :
    Copy code
    Error: invalid type: boolean `true`, expected a string
          at LibraryEngine.loadEngine (node_modules/@prisma/client/runtime/index.js:23613:27)
          at processTicksAndRejections (internal/process/task_queues.js:97:5)
          at LibraryEngine.instantiateLibrary (node_modules/@prisma/client/runtime/index.js:23557:7)
    Anyone got any idea why? When not using
    nApi
    it works fine.
    r
    j
    • 3
    • 32
  • i

    Ian

    07/13/2021, 3:41 PM
    Copy code
    enum PostType {
      default
      photo
      video
    }
    
    // --------------------------------------------------------------
    // THIS IS STRUCTURED VIA MULTI TABLE INHERITANCE
    // POST as SUPERTYPE which means table of common fields
    // PHOTO and VIDEO as SUBTYPE which means table for specific fields
    //
    // PROS -> Easy to add subtype
    //.     -> No need for polymorphic association (Just put the relation on the base class)
    //.     -> Can atleast achieve "IMPOSSIBLE STATE SHOULD BE IMPOSSIBLE" (Depends)
    //      -> Clear structure (No bloated table for unrelated fields)
    // CONS -> JOINS???
    //.     -> WHAT ELSE???
    // --------------------------------------------------------------
    // SUPERTYPE
    model Post {
      user   User   @relation(fields:[userId], reference: [id])
      userId String
      id     String @id @default(cuid())
      text   String
      type   PostType
    }
    
    // SUBTYPE
    model Photo {
      post   Post @relation(fields:[id], reference: [id])
      id     String @id @default(cuid())
    
      url    String
      width  Int
      height Int
    }
    
    // SUBTYPE
    model Video {
      post        Post @relation(fields:[id], reference: [id])
      id          String @id @default(cuid())
    
      url         String
      aspectRatio Float
    }
    
    // ---------------------------------------
    // SINGLE TABLE INHERITANCE
    // PROS -> Single Table (No joins needed)
    //.     -> WHAT ELSE???
    // CONS -> Nullable fields for uncommon column
    //      -> Adding subtype requires altering the whole table
    //.     -> Bloated
    // ---------------------------------------
    
    model Post {
      user   User   @relation(fields:[userId], reference: [id])
      userId String
      id     String @id @default(cuid())
      text   String
      type   PostType
    
      url    String
    
      width  Int? // Nullable here
      height Int? // Nullable here
    
      aspectRatio Float? // Nullable here
    }
    
    WHAT WOULD BE YOUR GO TO CHOICE??
    A. Multi-Table Inheritance (MTI)
    B. Single-Table Inheritance (STI)
    • 1
    • 2
  • i

    Ian

    07/13/2021, 3:48 PM
    I didn't put CTI because of some drawbacks also 1. Code Duplication (Right now you cant implement base class) 2. Polymorphic association because we dont have a base class to reference 3. Unique IDs (I think its not good on auto increment id)
  • m

    Marc

    07/13/2021, 4:08 PM
    Is the new MongoDB support not available for standalone mongo instances?
    Copy code
    Error:
    Invalid `prisma.model.deleteMany()` invocation:
    
    
      Error occurred during query execution:
    ConnectorError(ConnectorError { user_facing_error: None, kind: RawError { code: "unknown", message: "Command failed (IllegalOperation): This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.)" } })
    my prisma file
    Copy code
    datasource db {
      provider = "mongodb"
      url      = "<mongodb://localhost/prisma?retryWrites=false>"
    }
    
    generator client {
      provider = "prisma-client-js"
      previewFeatures = ["mongoDb"]
    }
    
    model Model {
      id  String  @id @default(dbgenerated()) @map("_id") @db.ObjectId
      username String
      ready Boolean
      tags  String[]
      priority Int
    }
    j
    m
    • 3
    • 2
  • g

    Gelo

    07/13/2021, 5:22 PM
    How to properly migrate database schema changes in production?
  • g

    Gelo

    07/13/2021, 5:27 PM
    Is this correct for production?
  • g

    Gelo

    07/13/2021, 5:28 PM
    r
    • 2
    • 3
  • a

    Aman Tiwari

    07/13/2021, 5:37 PM
    do prisma support real time sync?
    g
    t
    +2
    • 5
    • 10
  • w

    William Chantry

    07/13/2021, 10:39 PM
    We added a compount primary key using ``@@id([puckId, recordedDateTime])`` where those fields are mapped to
    pb_puck_id
    and `pb_recorded_timestamp`` It seemingly created the index we expected
    (pb_puck_id_pb_recorded_timestamp_idx)
    hoever, on each new migration, prisma attempts to drop the index. I’m pretty stumped, any ideas? Bonus: We made the table a timescaledb hypertable, which might be the issue
    r
    • 2
    • 3
  • i

    Ian

    07/14/2021, 6:35 AM
    does prisma studio need to be rerun again if I generate new client??
    d
    • 2
    • 1
  • n

    Nima

    07/14/2021, 8:19 AM
    Hi all, where is the best to request features? We are heavy users of Prisma studio and it would be super helpful if we could have a .ENV switcher in the studio app. Also would be good to know if refresh (CMD+R) reloads the connection or just redraws the GUI in the electron app? (cc @janpio @siddhant) Thank you!
    n
    j
    s
    • 4
    • 4
  • t

    Tomáš Kallup

    07/14/2021, 8:28 AM
    Hey, could someone help me with my issue? Prisma started crashing on me, but after some debugging I think it's because my schema is wrong. I have a many-to-many relation, but it doesn't use the
    id
    field (the DB schema is out of my controll, so I can't change the way it works) and I don't know how to represent it in the schema. Essentialy what I need, is to tell prisma it should use something like
    JOIN lbans_history lh ON lh.id = (SELECT MAX(lh.id) WHERE lh.uuid = lb.uuid ORDER BY date DESC)
    when requesting a relation using
    include: { history: true }
    , but I'm not sure if this is even possible.
  • s

    stephan levi

    07/14/2021, 8:38 AM
    Hi guys, i’m having an issue with a mutation of mine receiving the following error - Field ‘x’ of type ‘y’ must have a sub selection i will provide the schema and the code tnx
    r
    • 2
    • 2
  • m

    Moritz

    07/14/2021, 11:16 AM
    Congrats for releasing mongodb preview. I wondered if s.o. knows if mongodb shares the same limitations regards the connections limits like postgres does. So I'd like to know if its better suited for FaaS environments.
  • m

    manuel

    07/14/2021, 11:55 AM
    hey
  • m

    manuel

    07/14/2021, 11:55 AM
  • m

    manuel

    07/14/2021, 11:55 AM
    can't find the right nexus argument for type Date?
  • r

    Roman Schejbal

    07/14/2021, 11:58 AM
    @manuel there isn't one, but you can follow these tips https://github.com/graphql-nexus/nexus/issues/122
    🙌 1
  • m

    manuel

    07/14/2021, 12:00 PM
    I don't know, but shouldn't there be a dateTime args field out of the box, as it is basically part of every table?
  • r

    Roman Schejbal

    07/14/2021, 12:01 PM
    it is part of database but graphql doesn't have an implicit scalar for datetime, so you need to extend the scalar types and then come up with a custom argument type
    🇨🇿 1
    ✅ 2
    m
    • 2
    • 7
  • u

    user

    07/14/2021, 1:20 PM
    Prisma 2.27 Adds Preview Support for MongoDB Today we are excited to expand the range of supported databases with preview support of MongoDB. Try it out and let us know what you think!
    prisma cool 2
    mongodb 1
    prisma green 3
    prisma rainbow 1
    🙌 2
  • m

    Mehmet

    07/14/2021, 1:36 PM
    yay mongodb no more early access prisma rainbow
    🙌 2
  • v

    Vladi Stevanovic

    07/14/2021, 1:37 PM
    Please use the #mongodb channel to ask questions, share feedback and information about Prisma + MongoDB 💚 In the meantime, here are some resources: • ✨ Prisma 2.27.0 release notes • ✨ *Blog post "*Prisma 2.27 Adds Preview Support for MongoDB" • ✨ Live Talk "_Making MongoDB Type Safe with Prisma_" @ MongoDB.live, today July 14th 19:45 CEST. • ✨ Video "_

    Using MongoDB with Prisma▾

    _" • ✨ Guide "_Getting Started with MongoDB from scratch_" • ✨ GitHub Feedback #8241: "_Preview feature feedback: MongoDB support_" • ✨ Free MongoDB stickers > https://pris.ly/mongo-stickers • ✨ MongoDB mini-newsletter > https://pris.ly/mongo • ✨ Preview support definition
  • l

    Luis Kuper

    07/14/2021, 1:42 PM
    Hi there, How is it possible to query the following with prisma: i want to query a list of elements, and wanna add a uniqueness for a specific attribute for the results i recieve (so that there are no two results with the same value in the '_uniqueness-key',_ although there are multiple with the same value for that key in the database_)_. Example Schema:
    Copy code
    model Entry {
      id        String   @id
      category  String
    }
    Having the Entry model filled with data:
    Copy code
    id: '0', category: 'A'
    id: '1', category: 'A'
    id: '2', category: 'B'
    id: '3', category: 'C'
    id: '4', category: 'B'
    executing the query for I would like to recieve all queries, where the value of category hasn't been fetched before into the resulting data:
    Copy code
    id: '0', category: 'A'
    id: '2', category: 'B'
    id: '3', category: 'C'
    Any ideas?
    r
    • 2
    • 5
  • m

    Mischa

    07/14/2021, 2:21 PM
    Hi I've been posting a bit on GitHub trying to share what I'm trying to accomplish with DB migrations and adding a prisma lambda layer to functions in my CDK app. I created a WIP PR to try to put my ideas into code to create reusable constructs and utilities for using Prisma in lambda functions with CDK. Suggestions and feedback would be most appreciated: https://github.com/jetbridge/jetkit-cdk/pull/13
  • u

    user

    07/14/2021, 3:46 PM
    Using MongoDB with Prisma

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

    MongoDB is currently supported as a preview feature in Prisma. In this video, Ryan Chenkie walks through how to use MongoDB in a Prisma project, including instructions on how to connect to a remote MongoDB database, create documents, relate collections together, and more. Learn more about Prisma: ◭ Website: https://www.prisma.io​​​ ◭ Docs: https://www.prisma.io/docs​​​ ◭ Quickstart: https://www.prisma.io/docs/getting-started/quickstart-typescript
  • k

    Kent C. Dodds

    07/14/2021, 3:58 PM
    Hiya friends 👋 I need some help with something. I'm using the Browser MediaRecorder API to record the user's audio. I'm encoding it to base64 so I can stick it in an
    <audio />
    src. I'm not sure whether there's another way to do that without creating an actual file. The files are about 3 minutes long or so and I'll probably not store more than 100-200 at any given time, and they won't be written/read very often. Anyway, I need to persist this to my Postgres db. I understand that base64 is a pretty poor way to store this data because it can be rather large. People have suggested I use a binary type and store it like that. My question is, how do I serialize a
    base64
    string as binary to store it in the db, and then deserialize it when it needs to be read. Second related question, does anyone know whether there's another way I can do this to avoid base64 while still allowing me to use what's been recorded directly in an
    <audio />
    Note a hard requirement is to not actually create files. That's just not going to happen here. Hopefully that makes sense. Thanks for the help!
    👀 1
    d
    • 2
    • 1
1...457458459...637Latest