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

    Alban Kaperi

    05/17/2022, 1:31 PM
    Guys what do you use to seed fake data, I just saw that faker is removed npm
    n
    • 2
    • 1
  • a

    Alban Kaperi

    05/17/2022, 1:33 PM
    When I use '@faker-js/faker'' I get an error when I try to assign values let's say: name: faker.name The error says
    Copy code
    Type 'Name' is not assignable to type 'string'.
    m
    r
    • 3
    • 5
  • j

    Jason Kleinberg

    05/17/2022, 2:12 PM
    Does anyone have a good understanding of the Prisma middleware? What is the return value of the middlware callback used for? How are errors handled? The documentation is silent on these questions. They only really have simple examples.
    r
    • 2
    • 6
  • j

    Julien Demarque

    05/17/2022, 2:39 PM
    I am trying to understand [] modifier. I got something like:
    Copy code
    model BaseVariable {
      options String[]
    }
    What is odd is that prisma.baseVariable.create doesn't require me to fill the options argument, so I got baseVariables with options set to null in my postgresdb. But! if I try to assign null to options in prisma.baseVariable.create I get a type error.
    r
    • 2
    • 1
  • d

    Danilo Cadena

    05/17/2022, 2:48 PM
    Hi, How can I change the database provider from unit tests because it does not allow the "env" function to be used ?
    j
    • 2
    • 1
  • j

    Jason Kleinberg

    05/17/2022, 2:57 PM
    Is there a way to signal to the Prisma Rust query engine to clear all of the connections, but not close? The only way we can manage the connections is to
    $disconnect
    , but reconnecting takes a long time in tests (and takes longer as we go along for some reason).
    n
    • 2
    • 1
  • d

    Dhwanik Panchal

    05/17/2022, 4:38 PM
    Hey everyone. I started checkout out Prisma today and I am planning to use Prisma for a project in my company. Our project uses a multi database architecture. Would it possible to connect to multiple data sources using Prisma? If so, can someone point me to a good article/video/blog about that particular use case? Thanks much!
    a
    n
    • 3
    • 2
  • m

    Mattia Romeo

    05/17/2022, 6:47 PM
    Is there an error code for attempting to create an object with a duplicate id (i.e. an id that is already associated with another object in the database)?
    r
    • 2
    • 5
  • b

    Briggs

    05/17/2022, 9:42 PM
    Hey all I have a feature request that I think would be very powerful (sorry if this is not the right place for this) so say we could pass in the following to any CRUD operation
    Copy code
    const result = await prisma.user.create({
        data: {
          email: '<mailto:abc@123.com|abc@123.com>',
          firstName: 'abc',
          lastName: 'xyz',
          type: UserType.OWNER,
        },
        context: blah,
      });
    context could be of any type so we could then pick that up in the middleware
    Copy code
    export async function PubSubMiddleWare(
      params: Prisma.MiddlewareParams,
      next: (params: Prisma.MiddlewareParams) => Promise<any>
    ) {
      const { action, model, args } = params;
      const { context } = args;
      pubsub
          .publish(`${params.model}_changed`, {
            mutation: action,
            model,
            node: result,
            context
          })
    }
    r
    n
    • 3
    • 3
  • p

    Pieter

    05/17/2022, 10:47 PM
    @janpio we running into the issue you posted 7 days ago https://github.com/prisma/prisma/issues/13396
    r
    j
    • 3
    • 12
  • d

    daemon

    05/18/2022, 2:46 AM
    Can anyone share his
    bash
    script to run
    npx prisma migrate deploy
    and afterwards start the node process? I think there is some waiting involved right? Trying to dockerize the app so I can run it in aws
    r
    • 2
    • 5
  • d

    daemon

    05/18/2022, 2:53 AM
  • l

    lax

    05/18/2022, 4:08 AM
    Hey guys, how can i do Cascade delete in one-to-one relation. example: model Account { id String @id profileId String @unique profile Profile @relation(_fields_: [profileId], _references_: [id], _onDelete_: Cascade) } model Profile { id String @id account Account? }
  • l

    lax

    05/18/2022, 4:09 AM
    On profile delete account is getting deleted but i want the profile to get deleted on deleting account.
    c
    • 2
    • 4
  • c

    Chris Tsongas

    05/18/2022, 5:06 AM
    Does anyone know, when using Postgres is it possible to use @@index to create indexes on generated columns?
    n
    • 2
    • 2
  • d

    Denis Goncharenko

    05/18/2022, 5:12 AM
    Hi buddies! What’s wrong? Why userId has ‘never’ type? Meanwhile, user: {connect} works fine. This is happening when I add connection between ‘Talk’ and ‘Dialogue’. When ‘Talk’ connected only with ‘User’ model, it works fine with userId. The prisma version is 3.14
    e
    r
    • 3
    • 16
  • d

    Davedavedave

    05/18/2022, 11:20 AM
    Hey, general question regarding integration / E2E testing with nestJS & jest: we do the following: globalSetup -> Migrate & seed Database. run test suite against docker-compose DB This works... But we have a case where we need to match a snapshot with our generated Export and need the entry's ids to match. so we would love to do something like this (unrelated to my eg above): (fresh db on a test basis, not globalTestSetup basis)
    Copy code
    describe("UserService", () => {
      let connection: Connection
    
      beforeAll(async (done) => {
        connection = await useRefreshDatabase({ connection: 'memory' })
        await useSeeding()
    
        const user = await factory(User)().make()
        const createdUser = await factory(User)().create()
    
        await runSeeder(CreateUserSeed)
        done()
      })
    
      afterAll(async (done) => {
        await tearDownDatabase()
        done()
      })
    
      test('Should ...', () => { ... })
    })
    Can anybody chime in
    r
    l
    • 3
    • 18
  • s

    Shivam Singh

    05/18/2022, 1:10 PM
    I am writing an update API which has this block of code.
    Copy code
    await this.prismaService.person.update({
          where: {
            id,
          },
          data: {
            name,
            configuration: {
              update: configuration,
            },
            address,
            age,
          }
    })
    Now
    name
    ,
    address
    and
    age
    comes from request body and might be empty. I want to update these properties only if they are not empty. Is there a way to do so?
    r
    n
    • 3
    • 3
  • m

    Michael Roberts

    05/18/2022, 1:28 PM
    Does anyone have a solution that allows the type declarations generated by prisma to be shared across projects without the need for the schema.prisma file?
    👀 1
  • r

    Richard Kaufman-López

    05/18/2022, 1:36 PM
    As a related question to the one above, what is recommended if I want to use Prisma and the same DB in two different projects? Should I introspect to generate the schema on whichever project is behind?
  • m

    Michael Roberts

    05/18/2022, 2:05 PM
    As an update to my above question, I have figured out a way to share generated prisma type declarations across multiple projects. Let me know if anybody would like to utilise this method.
    r
    • 2
    • 3
  • j

    Jonas Schultheiss

    05/18/2022, 2:56 PM
    oy, i have two models, Vehicle and Driver. They are related by a one to one relation, which marks which car is currently occupied by wich driver. the relation is marked as optional on both ends. the problem i now face is that i can't create a vehicle, as i receive the following exception: "Null constraint violation on the fields: (
    driverId
    )". Do you know how i could approach this error?
    r
    • 2
    • 8
  • a

    Aaron Waller

    05/18/2022, 3:23 PM
    Is it possible in Prisma to get random records? I want to get 10 random posts from my Post table. with
    prisma.posts.count();
    I can get the Table size, and with
    Math.random()
    I generated 10 random int values. How can I now query my database and get 10 random posts?
    ⬆️ 1
    d
    r
    +3
    • 6
    • 10
  • j

    Joshua Snyder

    05/18/2022, 6:49 PM
    Does
    set:[]
    for a related record in a
    prisma.update()
    call where that related record has cascading deletes, delete the disconnected records?
    n
    • 2
    • 1
  • m

    Michael Roberts

    05/18/2022, 7:19 PM
    Hi there, I’m struggling to understand how to create objects using prisma upsert, I’m getting type validation issues yet I’m 99% certain I’m providing the correct data, could anyone give me so upset examples?
  • m

    Michael Roberts

    05/18/2022, 7:35 PM
    Sooooo many bugs, why can’t I import SomeModelCreateInput from @prisma/client 😞
  • m

    Michael Roberts

    05/18/2022, 7:36 PM
  • m

    Michael Roberts

    05/18/2022, 7:36 PM
    Yet in .prisma/client it exists?
    j
    • 2
    • 3
  • m

    Michael Roberts

    05/18/2022, 7:36 PM
  • p

    Peter Belbin

    05/18/2022, 8:48 PM
    Is anyone else seeing issues with
    upsert
    functionality? I have a simple loop iterating through a list of records that should be created (if not found) or simply retrieved (ie: update: {} // no change ), and the records do exist that are being upserted. First item in the list works as it should, but 2nd item is not. The record exists in the db, but I'm getting
    Error: Query upsertOneUser is required to return data, but found no record(s).
    (the entity object is 'User'). Prisma 3.14.0 is being used. Worked fine with 3.12.0.
    n
    • 2
    • 1
1...575576577...637Latest