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

    Barnaby

    12/29/2021, 2:30 PM
    then just generate some unique ID (UUID v4 would be a solid choice) to link the two
  • b

    Barnaby

    12/29/2021, 2:31 PM
    name the file in S3 that UUID and store the UUID in the database to act as a “pointer”
  • w

    Winter

    12/29/2021, 2:32 PM
    thanks! @Barnaby. I have used S3, I'll look to it.
  • u

    user

    12/29/2021, 2:51 PM
    Going Fully Serverless: migrating a live Prisma project from MySQL to PlanetScale with zero downtime

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

    In this video, you will learn how to use PlanetScale's import service to migrate from AWS RDS (or any other MySQL instance) to PlanetScale with zero downtime. Daniel will migrate the database of a live Prisma app deployed to Vercel making the app fully serverless. The Prisma Data Platform will also be used to verify the migration and make sure that all data is replicated correctly. PlanetScale database imports: https://docs.planetscale.com/concepts/database-imports Prisma & PlanetScale open issue: https://github.com/prisma/prisma/issues/7292 Prisma Data Platform http://cloud.prisma.io/ Source code: https://github.com/2color/ama-prisma Timestamps: 00:00 : Introduction 00:37 : Exploring the app's source code 01:43 : Adjusting the Prisma schema and setting referential integrity 03:47 : Creating a migration to remove foreign keys 04:40 : Running the migration aginst the Production MySQL on AWS RDS 05:10 : Configuring MySQL for the import into PlanetScale 06:33 : Importing (setting up replication) from MySQL to PlanetScale 08:19 : Adding the PlanetScale DB to the Prisma Data Platform 09:26 : Verifying that replication with the Data Browser in the Prisma Data Platform 10:46 : Updating the environment variable on Vercel 13:55 : PlantetScale specific configuration: removing migration deployments from build process 1535 Summary
    ❤️ 2
  • c

    Carlos

    12/30/2021, 3:15 AM
    Hello everyone, Does anybody know if it is possible to use an optional nested createMany?
    const createUserAndPost = await prisma.user.create({
    data: { email: ‘elsa@prisma.io’, name: ‘Elsa Prisma’, posts: { create: [ { title: ‘How to make an omelette’ }, { title: ‘How to eat an omelette’ }, ], }, }, }) In this example, I would like to create none, one or more post. So how do I handle if there are no post to create? How can I tell prisma to not throw any errors?
    a
    • 2
    • 1
  • s

    Sachin Bhattarai

    12/30/2021, 6:32 AM
    Hello! Can anyone help me, how can we generated time series in prisma to get records count for each day/week/month?
  • a

    Andrew Ross

    12/30/2021, 2:49 PM
    I'm trying to containerize a nestjs+prisma build and am having a hard time figuring out how to get prisma resolved when the container starts Should I be including the
    prisma
    package as a regular dependency as well for a container since typedefs references
    ./node_modules/.prisma/client/index.d.ts
    ?
    Copy code
    yarn run v1.22.15
    
    $ prisma generate node dist/src/nest/main.js
    
    > Downloading Prisma engines for Node-API for linux-musl [] 0%> Downloading Prisma engines for Node-API for linux-musl [] 1%> Downloading Prisma engines for Node-API for linux-musl [] 2%> Downloading Prisma engines for Node-API for linux-musl [] 3%> Downloading Prisma engines for Node-API for linux-musl [] 4%> Downloading Prisma engines for Node-API for linux-musl [] 5%> Downloading Prisma engines for Node-API for linux-musl [] 6%> Downloading Prisma engines for Node-API for linux-musl [] 7%> Downloading Prisma engines for Node-API for linux-musl [] 8%> Downloading Prisma engines for Node-API for linux-musl [] 9%> Downloading Prisma engines for Node-API for linux-musl [] 10%> Downloading Prisma engines for Node-API for linux-musl [] 11%> Downloading Prisma engines for Node-API for linux-musl [] 12%> Downloading Prisma engines for Node-API for linux-musl [] 13%> Downloading Prisma engines for Node-API for linux-musl [] 14%> Downloading Prisma engines for Node-API for linux-musl [] 15%> Downloading Prisma engines for Node-API for linux-musl [] 16%> Downloading Prisma engines for Node-API for linux-musl [] 17%> Downloading Prisma engines for Node-API for linux-musl [] 19%> Downloading Prisma engines for Node-API for linux-musl [] 20%> Downloading Prisma engines for Node-API for linux-musl [] 21%> Downloading Prisma engines for Node-API for linux-musl [] 22%> Downloading Prisma engines for Node-API for linux-musl [] 23%> Downloading Prisma engines for Node-API for linux-musl [] 24%> Downloading Prisma engines for Node-API for linux-musl [] 25%> Downloading Prisma engines for Node-API for linux-musl [] 26%> Downloading Prisma engines for Node-API for linux-musl [] 27%> Downloading Prisma engines for Node-API for linux-musl [] 28%> Downloading Prisma engines for Node-API for linux-musl [] 30%> Downloading Prisma engines for Node-API for linux-musl [] 31%> Downloading Prisma engines for Node-API for linux-musl [] 32%> Downloading Prisma engines for Node-API for linux-musl [] 33%> Downloading Prisma engines for Node-API for linux-musl [] 34%> Downloading Prisma engines for Node-API for linux-musl [] 35%> Downloading Prisma engines for Node-API for linux-musl [] 36%> Downloading Prisma engines for Node-API for linux-musl [] 37%> Downloading Prisma engines for Node-API for linux-musl [] 38%> Downloading Prisma engines for Node-API for linux-musl [] 39%> Downloading Prisma engines for Node-API for linux-musl [] 40%> Downloading Prisma engines for Node-API for linux-musl [] 41%> Downloading Prisma engines for Node-API for linux-musl [] 42%> Downloading Prisma engines for Node-API for linux-musl [] 43%> Downloading Prisma engines for Node-API for linux-musl [] 44%> Downloading Prisma engines for Node-API for linux-musl [] 45%> Downloading Prisma engines for Node-API for linux-musl [] 46%> Downloading Prisma engines for Node-API for linux-musl [] 47%> Downloading Prisma engines for Node-API for linux-musl [] 48%> Downloading Prisma engines for Node-API for linux-musl [] 49%> Downloading Prisma engines for Node-API for linux-musl [] 50%> Downloading Prisma engines for Node-API for linux-musl [] 51%> Downloading Prisma engines for Node-API for linux-musl [] 52%> Downloading Prisma engines for Node-API for linux-musl [] 53%> Downloading Prisma engines for Node-API for linux-musl [] 54%> Downloading Prisma engines for Node-API for linux-musl [] 55%> Downloading Prisma engines for Node-API for linux-musl [] 56%> Downloading Prisma engines for Node-API for linux-musl [] 57%> Downloading Prisma engines for Node-API for linux-musl [] 59%> Downloading Prisma engines for Node-API for linux-musl [] 60%> Downloading Prisma engines for Node-API for linux-musl [] 61%> Downloading Prisma engines for Node-API for linux-musl [] 62%> Downloading Prisma engines for Node-API for linux-musl [] 63%> Downloading Prisma engines for Node-API for linux-musl [] 64%> Downloading Prisma engines for Node-API for linux-musl [] 65%> Downloading Prisma engines for Node-API for linux-musl [] 66%> Downloading Prisma engines for Node-API for linux-musl [] 67%> Downloading Prisma engines for Node-API for linux-musl [] 68%> Downloading Prisma engines for Node-API for linux-musl [] 69%> Downloading Prisma engines for Node-API for linux-musl [] 70%> Downloading Prisma engines for Node-API for linux-musl [] 71%> Downloading Prisma engines for Node-API for linux-musl [] 72%> Downloading Prisma engines for Node-API for linux-musl [] 73%> Downloading Prisma engines for Node-API for linux-musl [] 74%> Downloading Prisma engines for Node-API for linux-musl [] 75%> Downloading Prisma engines for Node-API for linux-musl [] 76%> Downloading Prisma engines for Node-API for linux-musl [] 77%> Downloading Prisma engines for Node-API for linux-musl [] 78%> Downloading Prisma engines for Node-API for linux-musl [] 79%> Downloading Prisma engines for Node-API for linux-musl [] 80%> Downloading Prisma engines for Node-API for linux-musl [] 81%> Downloading Prisma engines for Node-API for linux-musl [] 82%> Downloading Prisma engines for Node-API for linux-musl [] 83%> Downloading Prisma engines for Node-API for linux-musl [] 84%> Downloading Prisma engines for Node-API for linux-musl [] 85%> Downloading Prisma engines for Node-API for linux-musl [] 86%> Downloading Prisma engines for Node-API for linux-musl [] 87%> Downloading Prisma engines for Node-API for linux-musl [] 88%> Downloading Prisma engines for Node-API for linux-musl [] 89%> Downloading Prisma engines for Node-API for linux-musl [] 90%> Downloading Prisma engines for Node-API for linux-musl [] 91%> Downloading Prisma engines for Node-API for linux-musl [] 92%> Downloading Prisma engines for Node-API for linux-musl [] 93%> Downloading Prisma engines for Node-API for linux-musl [] 94%> Downloading Prisma engines for Node-API for linux-musl [] 95%> Downloading Prisma engines for Node-API for linux-musl [] 96%> Downloading Prisma engines for Node-API for linux-musl [] 97%> Downloading Prisma engines for Node-API for linux-musl [] 98%> Downloading Prisma engines for Node-API for linux-musl [] 99%> Downloading Prisma engines for Node-API for linux-musl [] 100%Prisma schema loaded from prisma/schema.prisma
    
    Error: 
    
    Error: ENOENT: no such file or directory, copyfile '/node_modules/@prisma/index.d.ts' -> '/node_modules/@prisma/client/index.d.ts'
    
    
    
    ✔ Generated DBML Schema to ./docs/database in 22ms
    
    
    ✔ Generated Prisma Docs Generator to ./docs/prisma-docs-generated in 93ms
    
    
    ✔ Generated Prisma NestJS/GraphQL to ./src/nest/.generated/prisma-nestjs-graphql in 2.29s
    
    
    error Command failed with exit code 1.
    
    info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command
    b
    • 2
    • 6
  • d

    Dustin Sorensen

    12/30/2021, 5:12 PM
    I feel a bit silly for asking this, but I'm planning on writing a custom generator and for the life of me I can't seem to find any documentation related to how to go about building one. I've looked at the src for existing custom generators as a starting point, but a well defined reference doc would be super helpful. Does one exist?
    n
    b
    • 3
    • 5
  • d

    Danny SMc

    12/30/2021, 5:39 PM
    Hey all, this might sound silly, but slightly confused. So I am using Prisma with a Discord.JS bot, and currently I am working on a faction-based bot, and so far Prisma has been an absolute delight to work with compared to other ORM's I have used with TypeScript. I am currently stuck with a where clause, primarily, I am working with two models, where I have my faction, that then contains a list of faction channels as a relation many to one, so many channels can be assigned to a single faction, but a single channel would not be linked to many factions. Faction Model
    Copy code
    model Faction {
      id          String           @id @default(dbgenerated()) @map("_id") @db.ObjectId
      name        String
      roleId      String
      image       String           @default("#000000")
      description String           @default("No description has been set.")
      colour      String?
      rules       String           @default("No rules have been set.")
      channels    FactionChannel[]
      categoryId  String
      owner       User             @relation(name: "OwnedFactions", fields: [ownerId], references: [id])
      ownerId     String
      admins      String[]
      members     String[]
      guildId     String
      balance     Int              @default(0)
      wins        Int              @default(0)
      losses      Int              @default(0)
      draws       Int              @default(0)
      warnings    FactionWarning[]
      bans        FactionBan[]
      created     DateTime         @default(now())
      updated     DateTime         @updatedAt
      audit       FactionAudit[]
    }
    Faction Channel Model
    Copy code
    model FactionChannel {
      id         String             @id @default(dbgenerated()) @map("_id") @db.ObjectId
      discordId  String             @unique
      name       String
      type       FactionChannelType @default(TEXT)
      isCategory Boolean            @default(false)
      faction    Faction            @relation(fields: [factionId], references: [id])
      factionId  String
      claimable  Boolean            @default(false)
      admin      Boolean            @default(false)
    }
    So far, all is working fine, I have created two factions with 4 channels each, and this seems to work nicely, but I am trying to figure out how to query the faction based on where a certain channel exists, for example, if a user in a specific discord channel wants to know more about the faction like it's monetary balance, or it's total wins, I need to be able to lookup the faction based on the channel they are in, so at the moment, I have done:
    Copy code
    const faction = await this.prisma.faction.findFirst({
      where: {
        channels: {
          some: {
            discordId: channelId,
          },
        },
      },
    });
    The above is failing to return any results, even though the channel IS part of the faction. Any ideas what I am doing wrong here, help would be appreciated.
  • v

    Vilke

    12/30/2021, 8:04 PM
    Hey i have validated csv files, done with fast-csv package. I have problem with types when seeding database. Should I transfer csv to json with csvToJson: If you want that a number will be printed as a Number type, and values true or false is printed as a boolean Type, use:
    Copy code
    csvToJson.formatValueByType().getJsonFromCsv(fileInputName);
  • d

    Danny SMc

    12/31/2021, 12:44 AM
    I have a type, which has a relation, but for some reason, the "type" does not include the relation, so what is the actual TypeScript type for that model WITH the relationship?
  • s

    Sebastian Messier

    12/31/2021, 1:38 AM
    i am sharing a DB with a python app that uses sqlalchemy. Any tips on having my prisma client ignore tables managed by that external app? every migration is stumped by the existence of this single table. Would be awesome to have it be ignored, if possible.
  • r

    Robert Fish

    12/31/2021, 3:19 AM
    Do we have know if there's any plans to support astra db in the future?
  • u

    user

    12/31/2021, 7:50 AM
    What's new in Prisma? (Q4/21) Learn about everything that has happened in the Prisma ecosystem and community from October to December 2021.
  • j

    Jeffrey Wang

    12/31/2021, 6:30 PM
    Apologize if this has been asked or talked about already but - I am looking for a way to generate CRUD Koa routes that wrap Prisma. Are there any good codegen tools for any of the Node web frameworks (maybe this exists for Express?) that could do something like this?
  • a

    Awey

    12/31/2021, 11:20 PM
    Why is it when I see examples of using
    update
    with prisma
    Copy code
    prisma.post.update({
      where: { id: postId },
      data: { ...data }
    })
    How come they never check that the resource belongs to the person making the call to update? Even if the route is protected wouldn't that allow anyone who is authenticated to update resources that don't belong to them?
    m
    r
    • 3
    • 11
  • e

    esau

    01/01/2022, 6:33 AM
    Does anyone know the best way to filter for items on the existence of a related record in a one-to-one? Docs state the ability to do this on a one to many with none: or some: but I don't see anything on a one to one. Thanks!
  • d

    Dregond

    01/02/2022, 5:22 AM
    has there been any update regarding this https://github.com/prisma/prisma/issues/3385 ?
  • d

    Dregond

    01/02/2022, 5:22 AM
    or is there another best practice to achieve this ?
  • m

    Mischa

    01/02/2022, 9:33 AM
    is it possible to use the postgres
    tstzrange
    data type with prisma?
  • r

    Rune Jørgensen

    01/02/2022, 11:18 AM
    Can anybody confirm that the indentation issue from version 3.6.0 is fixed 🤔? I'm still experiencing the issue on v. 3.7.0, and https://github.com/prisma/language-tools/issues/993 is marked as closed. (it's probably just me having some issues with my local setup)
  • a

    Aviv Nahum

    01/02/2022, 11:39 AM
    Hey 🙂 I have a Typescript monorepo with many packages accessing the same DB - what is the best practice for it? Having a separate package with the prisma client exported and just accessing it from all other packages? Only exposing the types and not the client itself? Ty
  • g

    Gaurav Sharma

    01/02/2022, 1:31 PM
    Any plans on providing the 'Query Console' for local development?
    n
    • 2
    • 2
  • g

    Gaurav Sharma

    01/02/2022, 1:31 PM
    Really cool to try out prisma queries before implementing them, would love to see it land on local development flow.
    prisma rainbow 2
  • g

    Gaurav Sharma

    01/02/2022, 1:31 PM
    ❤️
  • r

    Robert Fish

    01/02/2022, 1:38 PM
    @Aviv Nahum I'm wanting to know this answer too, just starting using nx with prisma
  • a

    A DSJ

    01/02/2022, 2:15 PM
    Hello, I might be wrong but in the prisma doc https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#relation-filters before and after EVERY there are the 2 same example. It feels wrong
    n
    • 2
    • 1
  • e

    ezeikel

    01/02/2022, 2:52 PM
    Hey all! I have run into what seems like a similar issue to this GitHub issue i found while searching for a solution - https://github.com/prisma/prisma/issues/5294 the only issue is I have no idea what XOR is that the issue is referring to 😅 and I can't actually find a solution in the comment thread
    • 1
    • 7
  • j

    Joshua

    01/02/2022, 3:12 PM
    Hi, does anyone know if it's possible to prefer a "soft reset" (don't nuke the db /schema) over a "hard reset" when calling
    prisma migrate reset
    ? I'm finding that the hard reset is screwing with the various permissions I have set up (the credentials I give to my application can no longer access the schema as it's been destroyed / recreated) and I'd much prefer a
    --prefer-soft-reset
    cli option over creating a third set of credentials for the sole purpose calling reset such that they can read/write tables but not destroy the schema and thus triggering a "soft reset".
    n
    • 2
    • 2
  • h

    Huzaifah

    01/02/2022, 5:08 PM
    Can anyone help with this Prisma Studio issue: https://github.com/prisma/studio/issues/819
    n
    • 2
    • 2
1...528529530...637Latest