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

    Josh Williams

    11/28/2020, 3:55 AM
    Any idea on how to fix?
    b
    • 2
    • 4
  • t

    tylim

    11/28/2020, 6:02 PM
    heh guys, i want to create multiple user and return them, how can i make this type an array type?
  • t

    tylim

    11/28/2020, 6:02 PM
    Copy code
    export const seedUser = mutationField('seedUser', {
        type: 'User',
        args: {
            number: intArg(),
        },
        resolve: (_, { number }, { prisma }) => {
            return [...new Array(number)].map(() =>
                prisma.user.create({
                    data: {
                        userId: Math.random().toString(),
                        email: Math.random().toString(),
                        profile: {
                            create: { bio: '123', name: '456' },
                        },
                    },
                })
            )
        },
    })
  • t

    tylim

    11/28/2020, 6:03 PM
    ok, found it, by using list('User')
  • m

    Matthew Eman

    11/28/2020, 8:31 PM
    Hey could anyone point me in the right direction? When I run
    yarn prisma init
    (or any command really) im getting the following error message:
    Copy code
    Failed to get the definition file
    Error: couldn't find 'prisma.yml' file. Are you in the right directory?
  • m

    Matthew Eman

    11/28/2020, 8:34 PM
    Nevermind! I was able to resolve it
  • j

    Josh Williams

    11/28/2020, 11:24 PM
    is there a way to log in to a different github account for prisma? I revoked access to my first github account but prisma is remembering my account info anyways.
  • j

    Josh Williams

    11/28/2020, 11:25 PM
    I want to deploy a demo server under a different github account.
  • n

    Nafis Shah

    11/29/2020, 1:45 AM
    Quick question, what's the difference between this npm package https://www.npmjs.com/package/prisma and https://www.npmjs.com/package/@prisma/cli ? I am guessing the 2nd one is the Prisma 2.x while the first is just Prisma 1.x
    n
    • 2
    • 3
  • t

    tylim

    11/29/2020, 12:33 PM
    if my prisma schema file is getting bigger, how can i split it?
    ❓ 2
    n
    • 2
    • 1
  • t

    tylim

    11/29/2020, 7:07 PM
    so if i use t.crud, how should i change the argument?
    n
    • 2
    • 3
  • a

    Armaan Dhanji

    11/30/2020, 6:55 AM
    If i'm using NestJS to create typed DTO's and also return types for services and whatnot, can I just directly import and use the types generated from Prisma Client?
    n
    m
    • 3
    • 9
  • t

    tylim

    11/30/2020, 10:53 AM
    heh guys, i have model like this
    Copy code
    model User {
      id      String    @id
      email   String?   @unique
      profile Profile?
      product Product[]
      role    ROLE      @default(USER)
      orders   Order[]
    }
    
    model Order {
      id      Int          @id @default(autoincrement())
      buyerId String
      buyer   User         @relation(fields: [buyerId], references: [id])
      status  ORDER_STATUS
      seller  User         @relation(fields: [sellerId], references: [id])
    }
    User can be seller or buyer however this is giving me error
    n
    • 2
    • 5
  • t

    tylim

    11/30/2020, 10:54 AM
  • t

    tylim

    11/30/2020, 10:55 AM
    how can I relate both seller and buyer to user in order?
  • t

    tylim

    11/30/2020, 10:56 AM
    or i need to create another table, eg Sale, like this
  • t

    tylim

    11/30/2020, 10:56 AM
    Copy code
    model User {
      id      String    @id
      email   String?   @unique
      profile Profile?
      product Product[]
      role    ROLE      @default(USER)
      orders  Order[]
      sales   Sale[]
    }
    
    model Order {
      id      Int          @id @default(autoincrement())
      buyerId String
      buyer   User         @relation(fields: [buyerId], references: [id])
      status  ORDER_STATUS
    }
    
    model Sale {
      id       Int          @id @default(autoincrement())
      sellerId String
      seller   User         @relation(fields: [sellerId], references: [id])
      status   SALES_STATUS
    }
  • n

    Natalia

    11/30/2020, 1:00 PM
    👋 Join us at week’s events that are featuring or organised by Prisma: • Jamstack Berlin Meetup - today at 6:30PM CET, where Daniel Norman, Prisma's Developer Advocate, will give a talk titled Jamstack with Next.js and Prisma - 

    tune in here▾

    ; • Advanced TypeScript Trickery - December the 1st, 6PM CET - an open mic format hosted by Prisma, where we discuss all things TypeScript - 

    set a reminder on YouTube▾

    ; See you there! prisma cool
    prisma rainbow 1
    💚 1
  • n

    Natalia

    11/30/2020, 5:54 PM
    prisma cool Jamstack Berlin Meetup is live! Prisma's Dev Advocate, Daniel Norman, will be on soon to about Jamstack with Next.js and Prisma.

    Tune in here▾

    !
  • k

    KJReactor

    11/30/2020, 9:42 PM
    How can I create a new record of an entity
    A
    and connect to an existing record of entity
    B
    using
    B.id
    in the
    connect
    field ? the following is not working for me. The relationship is 1:1 so
    B.id
    should be valid as a unique key for
    connect
    , no?
    Copy code
    prisma.A.create({
        data: {
           ...,
           B: { connect: { id: ... } }
        }
    })
    r
    • 2
    • 13
  • d

    Dustin

    12/01/2020, 1:41 AM
    Anyone had a unique where clause not working with a string, enum, and Date? For some reason a findFirst works but not a findUnique or a nested connect - the findUnique returns null and the connect fails while the firsdFirst finds the only unique record .
    Copy code
    const findUnique = await this.prisma.availability.findUnique({
      where: {
        propertyId_date_status: {
          propertyId: 'cki4d4rn102310qqlri351ppf',
          status: AvailabilityStatus.AVAILABLE,
          date: new Date('2020-12-02T00:00:00.000Z'),
        }
      }
    });
    
    const findFirst = await this.prisma.availability.findFirst({
      where: {
        propertyId: 'cki4d4rn102310qqlri351ppf',
        status: AvailabilityStatus.AVAILABLE,
        date: new Date('2020-12-02T00:00:00.000Z'),
      }
    });
    
    console.log(findUnique); // <-- Null
    console.log(findFirst); // <-- Not null
    
    model Availability {
      date          DateTime
      property      Property              @relation(fields: [propertyId], references: [id])
      propertyId    String
      status        AvailabilityStatus    @default(AVAILABLE)
    
      @@unique([propertyId, date, status])
    }
    
    enum AvailabilityStatus {
      AVAILABLE
    }
    r
    • 2
    • 8
  • r

    raghib shahriyer

    12/01/2020, 7:27 AM
    Hi can anyone help ? I am getting "No Prisma Cloud secret is set. Metrics collection is disabled." how to fix this 😔
    r
    • 2
    • 4
  • b

    Bruno Casado

    12/01/2020, 3:24 PM
    guys can i post a question in here?
  • b

    Bruno Casado

    12/01/2020, 3:28 PM
    well, here we go. Guys i'm with a problem with default generated client ( node_modules ) I know that prisma uses hook to do the task , but it seems not work when my application is deployed using elastic beanstalk. The aws elb says that it do the npm install by it own, and if you need to install dev dependencies you have to add a variable to ignore --production. i tried do that, but it doesn't worked. After i puted the @prisma/cli in regular package area, but it seems the hook is not working in anyway. Someone faces this problem too?
    n
    r
    • 3
    • 8
  • j

    Jin

    12/01/2020, 4:14 PM
    Hey guys . I am a Mobile developer in Berlin.  I hope you guys are doing well in this time. I am looking for a partner for side project. • Someone who has passion and responsibility   • Server graphql developer based on prisma. • Prefer someone who can work together in person from time to time
  • j

    Joe Graham

    12/01/2020, 7:50 PM
    so i have a bit of a wierd question i have two tables 
    items
     and 
    item_versions
      (*note: sql server)
    Copy code
    create table items {
      id int IDENTITY(1,1) constraint items_pkey primary key,
      version int not null
    }
    
    create table item_versions {
     id int IDENTITY(1,1) constraint item_versions_pkey primary key,
     item_id int not null,
     version int not null,
     name nvarchar(15) not null
    }
    so in the above example i have a 1:* items -> item_versions but I also want to model 1:1 item_versions -> items, how would i model that in my prisma schema? and what keys would i need to define on the tables to have prisma be able to query that relationship?
  • j

    Joe Graham

    12/01/2020, 7:58 PM
    one problem i have seen above is that the relation would be required on both sides which presents a problem creating a new item without a corresponding item_version
  • t

    tylim

    12/02/2020, 12:40 AM
    heh guys, is nexus come with dataloader, or do i need to implement it myself?
    n
    • 2
    • 2
  • e

    Eddy Nguyen

    12/02/2020, 12:20 PM
    I’m using Prisma’s vscode extension but it’s showing error if I’m trying to use environment variable for
    binaryTargets
    . Does anyone knows how to fix this? ( I can still generate, migrate, etc. so I think it’s an extension issue..?)
    r
    • 2
    • 4
  • t

    tylim

    12/02/2020, 5:33 PM
    [nexus] why when i defined resolver for a field, it is no longer available in root?
    • 1
    • 4
1...407408409...637Latest