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

    Yanluis Ulloa

    06/18/2021, 7:03 PM
    Hi all. Thanks for the invitation and having me here!
  • y

    Yanluis Ulloa

    06/18/2021, 7:05 PM
    I have a question in case anybody can help me: Is there any way to filtering by Regular Expression pattern?
  • y

    Yanluis Ulloa

    06/18/2021, 7:06 PM
    I noticed there is a request open from 2018… https://github.com/prisma/prisma1/issues/1766
    j
    • 2
    • 4
  • e

    Eric Martinez

    06/18/2021, 9:41 PM
    Hey guys, shouldn't raw queries still work with the schema file? I'm having issues when writing a raw query using the model/fields names, if I use the table/mapped fields names it works. If I understand correctly this doc, model names and fields names should work correctly (https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access), or raw query is a 100% raw query and I misunderstood the doc?
    j
    • 2
    • 4
  • v

    Vinaya Sathyanarayana

    06/19/2021, 3:19 AM
    Any updates on Geo Fields like Point
  • a

    Alan

    06/19/2021, 4:16 AM
    I have a MySql column with type
    double(10,2)
    . How Prisma can handle it? if i run
    prisma migrate
    it will override my database to
    DOUBLE
    j
    • 2
    • 7
  • b

    bb2021

    06/19/2021, 5:06 AM
    are
    upsert
    and
    connectOrCreate
    somehow incompatible? 🤔 i've got something along the lines of:
    Copy code
    const director = someBoolean ? { connectOrCreate: { create: { name: 'Steven Spielberg' }, where: { name: 'Steven Spielberg' }  } } : undefined
    const movie = { contentId: 'some_id_here', title: 'Jaws', director }
    
    const upsertResult = await prisma.movie.upsert({ create: movie, update: movie, where: { contentId: movie.contentId } })
    // results in "The change you are trying to make would violate the required relation 'DirectorToMovie' between the 'Director' and 'Movie' models.
    for reference, the Movie model lists a director as being optional, which is why I'm so confused at it complaining that it would break a required relation. Not sure if it's important, but I'm using sqlite as the underlying db
    Copy code
    model Movie {
      id        Int @id @default(autoincrement())
      contentId String
      title     String
      director  Director?
    }
    
    model Director {
      id      Int @id @default(autoincrement())
      name    String @unique
      movie   Movie @relation(fields: [movieId], references: [id])
      movieId Int
    }
    r
    • 2
    • 1
  • i

    Ian

    06/19/2021, 9:54 AM
    Hello... Im new to prisma. Just getting started today. Now I just read the docs about include specially in one to many advantage. But im curious if I have the user and post relationship does user will return all the posts made by the user?? how will I do the first 5 posts only?
    r
    • 2
    • 3
  • i

    Ian

    06/19/2021, 10:29 AM
    How accurate will be the db introspection ? should we trust it? or should we trust it in most cases but still needed a user correction when pulled?
    j
    • 2
    • 7
  • r

    Ramesh

    06/19/2021, 1:19 PM
    Can some one help me on this problem?
  • r

    Ramesh

    06/19/2021, 1:20 PM
    https://stackoverflow.com/questions/67874745/prisma-one-to-many-relation-ship-insert-and-update
    r
    j
    • 3
    • 2
  • m

    Muhammed Kurel

    06/19/2021, 1:25 PM
    Guys! I just bought new macbook m1. I have this issue and I couldn't solve this.
    j
    h
    • 3
    • 4
  • c

    Cliff

    06/20/2021, 12:58 AM
    Hi All, any idea when
    Fuzzy/Phrase full text search
    will be available in prisma schema and client?
    m
    j
    r
    • 4
    • 5
  • d

    David Munro

    06/20/2021, 3:00 AM
    🤙
  • t

    Tom

    06/20/2021, 6:08 AM
    Hey, how can I prefix my prisma command with a dotenv command? It should be something like this:
    npx dotenv -e .env.development prisma db seed --preview-feature
    However I still get this error:
    Copy code
    Environment variables loaded from .env
    Error: This feature is currently in Preview. There may be bugs and it's not recommended to use it in production environments.
    Please provide the --preview-feature flag to use this command.
    Note that it also uses the wrong env. Found it: Just separate the two commands with --
    ✅ 2
    j
    • 2
    • 1
  • a

    Azhi Dahaka

    06/20/2021, 7:38 AM
    Hi everyone previously in older version of Prisma (using with Docker) locally I could've run Prisma playground and directly query Data Base but now I can't, now when I run prisma migrate dev , I see the below log : Datasource "db": PostgreSQL database "MyDBName", schema "public" at "localhost:5432" I think it has to do sth with this -> localhost:5432 Could somebody help me with this ?
    j
    • 2
    • 2
  • r

    Reinaldy Rafli

    06/20/2021, 2:42 PM
    Hi, I got this error when executing
    prisma.schema.findMany()
    . I can't seem to find what caused this on the documentation. On the table, there is 3 data already.
    Copy code
    "name": "NotFoundError",
    "clientVersion": "2.25.0"
    r
    • 2
    • 2
  • h

    Halvor

    06/20/2021, 4:30 PM
    Is it possible to use a "include" from another table in an aggregate query?
  • h

    Halvor

    06/20/2021, 4:36 PM
    I need to sum all columns in multiple tables.
  • a

    AlexSPx

    06/20/2021, 6:03 PM
    For some reason when I came to update a few models I started getting this errror
    Copy code
    Error: Cannot find module '@prisma/engines'
    r
    • 2
    • 1
  • a

    AlexSPx

    06/20/2021, 6:06 PM
    Tried
    npm i @prisma/engine
    but still gives the same error
  • i

    Ibrahim

    06/20/2021, 10:40 PM
    Hi, how do i generate optional Prisma Client Types for this schema
    Copy code
    // schema
    model User {
      id         Int     @id @default(autoincrement())
      facebookId String? @unique
      googleId   String? @unique
      profileURL String?
    }
    
    //desired type generated on the client
    export type User = {
      id: number
      facebookId?: string | null
      googleId?: string | null
      profileURL?: string | null
    }
    
    // what is really generated
    export type User = {
      id: number
      facebookId: string | null
      googleId: string | null
      profileURL: string | null
    }
    e
    r
    • 3
    • 2
  • a

    Albert Gao

    06/21/2021, 12:17 AM
    anyone has a working example of getting Prisma up and running against AWS Aurora Serverless with CDK? Can not get it work, it does not connect within the VPC 🥲
    s
    r
    • 3
    • 10
  • n

    Nitgo

    06/21/2021, 12:36 AM
    `page not found`: https://github.com/prisma/prisma-examples/blob/latest/typescript/rest-express/prisma/dev.db
    j
    r
    • 3
    • 2
  • a

    Azhi Dahaka

    06/21/2021, 5:28 AM
    Hi everyone , is there any way to seed your Database multiple times without running prisma reset command I am using the command down below (but it works just one time after migration and you need to reset to run it again)
    Copy code
    prisma db seed --preview-feature
    And I'm following this page: https://www.prisma.io/docs/guides/database/seed-database
    j
    • 2
    • 5
  • m

    Manthan Mallikarjun

    06/21/2021, 7:46 AM
    Interesting question for everyone, do people use
    ID
    or
    Id
    ? For example when adding a relation, do you do
    postId
    or
    postID
    ? I personally find myself doing
    ID
    but I noticed that the VSCode extension defaults to
    Id
    j
    • 2
    • 3
  • j

    jasci

    06/21/2021, 8:11 AM
    Hello everybody, have a few questions: I’ve got 2 schemas: prisma schema and app schema. Prisma generated types for me, also I’ve generated types for the app schema using
    graphql-code-generator
    . 1. How to properly ‘type’ the resolvers ? I typed the resolvers itself with types generated from the
    graphql-code-generator
    for example:
    Copy code
    const updateUser: MutationResolvers['updateUser'] = <resolver code>
    But the problem is - return type from the resolver (
    prisma.user.update
    call ) is User (prisma) and it does not include the relations, and here is the conflict ( ’Type ‘User’ is missing the following properties from type ‘User’: adminOf, employeeOf, accounts’ or similar ones ). Basically for every model/type I’ve got 2 type definitions and in many cases they differ. Here is the User type in the app schema:
    Copy code
    type User {
      email: String!
      firstName: String!
      lastName: String!
      phone: String
      billingAddress: Address
      shippingAddress: Address
      adminOf: [Company!]!
      employeeOf: [Company!]!
      accounts: [Account!]!
      adminOfVendors: [Vendor]
    }
    Here is typings for the User model (prisma):
    Copy code
    export type User = {
      id: string
      emailVerificationToken: string | null
      passwordResetToken: string | null
      superUser: boolean
      email: string
      firstName: string
      lastName: string
      password: string
      phone: string | null
      billingAddress: Prisma.JsonValue | null
      shippingAddress: Prisma.JsonValue | null
    }
    Here is typings for the User type (graphql-code-generator):
    Copy code
    export type User = {
      __typename?: 'User';
      email: Scalars['String'];
      firstName: Scalars['String'];
      lastName: Scalars['String'];
      phone?: Maybe<Scalars['String']>;
      billingAddress?: Maybe<Address>;
      shippingAddress?: Maybe<Address>;
      adminOf: Array<Company>;
      employeeOf: Array<Company>;
      accounts: Array<Account>;
      adminOfVendors?: Maybe<Array<Maybe<Vendor>>>;
    };
    Maybe there is some universal practice of typing the API with 2 main type files (for the prisma datamodel and app schema) ? I’m new to the typescript. 2. If my app schema defines some fields which are relations (User example):
    Copy code
    adminOf: [Company!]!
      employeeOf: [Company!]!
      accounts: [Account!]!
      adminOfVendors: [Vendor]
    I do need to use
    include
    in the Prisma Client in every resolver that should return User type? Because they are not returned by default. 3. T*ype resolvers:* For example I’ve got
    Company
    type and it has field
    admin
    which is of type User. When I write type resolvers for the
    Company
    type, specifically for the
    admin
    field, do I also need to use
    include
    in it (to get relations of the User) ? Example:
    Copy code
    const resolvers = {
      Query: {
        // ... 
      },
      Mutation: {
        // ... 
      },
      Company: {
        admin: (parent, args, context) => {
           return context.prisma.company.findUnique({
             where: { id: parent.id }
           }).user()
    
           // Or something like that
           return context.prisma.user.findUnique({
            where: { id: parent.userId },
            include: {
              some_relation_field: true
            }
          })
         }
       },
    }
    Sorry for a lot questions, thank you.
    e
    • 2
    • 6
  • d

    David Ilizarov

    06/21/2021, 9:04 AM
    Is it possible to use
    connect
    and update the connecting relation at the same time? Kinda like how you can use
    create
    to create a new relation.
    Copy code
    const createPost = await prisma.post.create({
      data: {
        title: "How to make croissants",
        author: {
          create: {
            email: "<mailto:viola@prisma.io|viola@prisma.io>",
            name: "Viola"
          }
        }
      }
    })
    I kinda want the same, but like...
    Copy code
    const createPost = await prisma.post.create({
      data: {
        title: "How to make croissants",
        author: {
          connect: {
            id: 10,
            data: {
              email: "<mailto:viola@prisma.io|viola@prisma.io>",
              name: "Viola"
            }
          }
        }
      }
    })
    I know that exact API is not available, but is there something simlar?
    r
    • 2
    • 2
  • a

    Albert Gao

    06/21/2021, 10:36 AM
    I can connect to my Aurora Serverless with this raw SQL lib: https://www.npmjs.com/package/serverless-postgres but the same setup is not working with Prisma…. do not know what is happening here…. 🥲
    j
    r
    • 3
    • 2
  • d

    Dregond

    06/21/2021, 11:25 AM
    Hi All just noticed this while preparing for a prisma related presentation: https://www.prisma.io/docs/getting-started/quickstart The package.json file in the quickstart project is missing "@types/node": "^15.12.4" so it throws an error when trying to run.
    r
    • 2
    • 1
1...446447448...637Latest