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

    Logan Lee

    01/18/2022, 8:15 PM
    how to update my model’s type definition instantly ? i am using typescript and when i changed a bit on my collection ( using mongodb). it took times after “prisma db pull” and i don’t know how long it will take 😞
  • l

    Logan Lee

    01/18/2022, 8:16 PM
    should i need to delete “index.d”?
  • m

    Mradul Jain

    01/19/2022, 6:41 AM
    hello everyone, how i can write a below query using prisma model
    select
    cases.case_number as caseNumber,
    inv.invNum,
    inv.matNum,
    cases.style,
    cases.case_sk as caseSk
    from fm_invoices_view inv
    left join(
    select case_number, case_sk, style from cases_details
    ) cases
    on
    SUBSTRING(cases.case_number, 0, CHARINDEX('-', cases.case_number)) = inv.matNum
    where
    inv.invNum = ${filter.invoiceId}
    group by
    inv.invNum,
    cases.case_number,
    cases.style,
    inv.matNum,
    cases.case_sk
  • j

    Jakub Figlak

    01/19/2022, 7:02 AM
    Hey, what kind of primary key do you use in your databases? I’d like to know your opinion about cuid vs autoincremented integer. What are the advantages of cuid? The way I see it is that autoinc is more human readable and possible to memorize if you need it and thus I think I’d stick to that. Am I missing something? What about performance? Does the kind of Id have any impact on that? Extra question - do you always use explicit IDs or rely on other unique values if they exist?
  • b

    Benny Kachanovsky

    01/19/2022, 8:06 AM
    @Jakub Figlak
    autoincrement
    means that if you expose these id to your users they can conclude stuff you dont want them to know. For example, user signs up and get the id of 1234, and then another user signs up he will get 12345. Now there are 2 stuff your users might know: 1. There are probably about 12345 users in your system 2. This is more important - they can try to impersonate to your users by knowing their id (they know that id 123 probably exists etc) So the best approach is to avoid predictable entities ids
    👍 1
  • u

    user

    01/19/2022, 8:31 AM
    Prisma Chats with Nika Music

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

    In this video, Marketing Associate Intern from Prisma's DevRel team Nika Music interviews...themselves? They talk about starting a job fresh out of university, Prisma's environment, and exciting projects. Connect with Nika: LinkedIn: http://linkedin.com/in/nika-music-231 Next: 👉 Previous video: Prisma Chats w/ Alex Ruheni

    https://youtu.be/4mC03wvmKPY▾

    00:30 - Intro 01:34 - Before Prisma 03:17 - Differences between university and company environments 04:28 - Most useful lesson learned 05:51 - Biggest challenge 06:40 - Favorite part of working at Prisma 08:16 - Most exciting project 10:10 - Advice for people entering tech world
  • b

    Benny Kachanovsky

    01/19/2022, 11:05 AM
    Hi, is there a way to reference an existing table that is not in Prisma's schema? for example i have existing User table. Im creating a Post model in Prisma that i want to have a foreign key to User. If there is not built-in way, the best option is change the generated migration files that responsible on the addition of Post model?
    n
    • 2
    • 1
  • f

    Franco Roura

    01/19/2022, 3:14 PM
    Anyone had this issue with Prisma unit testing? I copied and pasted the stuff from the docs, but it still reads
    prismaMock
    as undefined
  • m

    Michael Buller

    01/19/2022, 5:37 PM
    Hello all,
  • m

    Michael Buller

    01/19/2022, 5:38 PM
    I am having an issue with Prisma 1 to 1 relationships, prisma formats my relation with @unique which creates a unique constraint on the column. This makes it to where the field can only have 1 null in it. The opposite table is optional, I have set the relation with ? on them so that it reflects, but this @unique getting added prevents the data from saving after the first record is added to the system.
  • m

    Michael Buller

    01/19/2022, 5:42 PM
    Copy code
    model Intake {
       legalCase    LegalCase?         @relation("LegalCase_intake")
    }
    
    model LegalCase {  
      ...
      intakeId     String?         
      intake       Intake?         @relation(name: "LegalCase_intake", fields: [intakeId], references: [id])
  • m

    Michael Buller

    01/19/2022, 5:46 PM
    After I run prisma apply the intakeId looks like this ...
    Copy code
    intakeId     String?         @unique
    intake       Intake?         @relation(name: "LegalCase_intake", fields: [intakeId], references: [id])
  • m

    Michael Buller

    01/19/2022, 5:56 PM
    And when I try to save an Intake which gets created before the Legal Case...
    Copy code
    {
        "errors": [
            {
                "message": "\nInvalid `prisma.intake.create()` invocation:\n\n\n  Unique constraint failed on the constraint: `dbo.LegalCase`",
                "locations": [
                    {
                        "line": 2,
                        "column": 3
                    }
                ],
                "path": [
                    "created"
                ],
                "extensions": {
                    "code": "INTERNAL_SERVER_ERROR",
                    "exception": {
                        "code": "P2002",
                        "clientVersion": "3.8.1",
                        "meta": {
                            "target": "dbo.LegalCase"
  • m

    Michael Buller

    01/19/2022, 5:57 PM
    I put a ticket here https://github.com/prisma/prisma/issues/11272 I am also happy to pay for support, just dont know where to go.
  • k

    Kenneth Gitere

    01/19/2022, 6:41 PM
    Hello. Is there a way to revert migrations on prisma? I noticed that the generated migrations only ever "upgrade" the DB but never "downgrade" it if you want to rollback a migration. The options I see involve deleting your existing data and I wonder if there's any other alternative.
    d
    • 2
    • 1
  • m

    Michael Buller

    01/19/2022, 6:45 PM
    According to the documentation ... https://www.prisma.io/docs/concepts/components/prisma-migrate/prisma-migrate-limitations-issues#lack-of-rollbacks--down-migrations
  • m

    Michael Buller

    01/19/2022, 6:45 PM
    It is a known limitation
  • a

    Alexander Carney

    01/19/2022, 7:37 PM
    Hi there, I was wondering what would be the best way to return csv-formatted data from Prisma queries? Currently I run the results from my queries (from a relational database) through an external csv parser library, but I was wondering if Prisma could directly return the data in csv format, potentially with the use of $queryRaw if needed
  • m

    Michael Buller

    01/19/2022, 8:33 PM
    where do you want to run the csv formatter from?
  • m

    Michael Buller

    01/19/2022, 8:33 PM
    will it be on the web with a button click or simply a job in the background?
    a
    • 2
    • 2
  • f

    face boy

    01/19/2022, 9:30 PM
    Is there a way to view a PostgreSQL database hosted on Heroku using Prisma Studio?
  • m

    Michael Buller

    01/19/2022, 9:50 PM
    Easy, just put the connection string in
  • m

    Michael Buller

    01/19/2022, 9:50 PM
    you would likely run introspection first if you are starting with an empty database
  • m

    Michael Buller

    01/19/2022, 9:51 PM
    You can introspect your database using the 
    prisma db pull
     command of the Prisma CLI. Note that using this command requires your connection URL to be set in your Prisma schema `datasource`.
    f
    • 2
    • 2
  • b

    Boo

    01/19/2022, 10:26 PM
    is this redundant?
    Copy code
    tokenId      String  @map("token_id") @unique(map: "token_id") @db.VarChar(255)
    the
    @map
    and
    @unique
    both mapping to
    token_id
    do i have to
    @map
    here?
    s
    • 2
    • 2
  • a

    Ankit Aabad

    01/20/2022, 12:31 AM
    Yesterday I gave a webinar on Prisma

    https://www.youtube.com/watch?v=-td2zlTOvfw&t=1858s&ab_channel=AntStack▾

    prisma cool 2
    💯 1
    prisma rainbow 1
    n
    • 2
    • 2
  • k

    koenie-06

    01/20/2022, 10:40 AM
    I had the exact same code as i had before when it worked, and now it somehow doesn't work anymore
  • k

    koenie-06

    01/20/2022, 10:41 AM
    Although he still deletes the data of the DB
  • v

    Victor

    01/20/2022, 10:47 AM
    UPDATE: Answered the question myself, see comments 🐥 Hey guys, quick question. I'm adding
    onDelete: Cascade
    to the
    schema.prisma
    and pushing these changes to my MySQL database hosted on PlanetScale with
    npx db push
    . I then got the response;
    Copy code
    The database is already in sync with the Prisma schema.
    I then tried to delete a
    User
    -row, which should have deleted rows in different tables - but it did not. I'm wondering if I have to do something else for the cascading deletes to work on the PlanetScale db?
    prisma cool 2
    ✅ 3
    • 1
    • 3
  • t

    Thibaut De Maerteleire

    01/20/2022, 12:16 PM
    Does anybody know why I'm required to add the where prop to the upsert object and why I can only use the ID in the where statement?
    n
    c
    • 3
    • 5
1...534535536...637Latest