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

    Joey

    06/30/2022, 6:03 PM
    if i have ids with
    id String *@id*
    *@default*(cuid())
    , does that guarantee that no row will be created with the same id on any table, or is it just unique on that specific table?
    ✅ 1
    a
    • 2
    • 2
  • a

    Avery Yip

    06/30/2022, 6:11 PM
    Is there any place to read up on how upserts are implemented in Prisma? Im running upserts asynchronously and I'm running into issues where the
    push
    in the update is actually not being consistent. i.e. If I push
    1
    and
    2
    , only
    1
    is in the array
    Copy code
    items.map((item) =>
      table.upsert({
        where: {
          id: item.id,
        },
        create: {
          id: item.id,
          relatedIds: [item.relatedId],
        },
        update: {
          relatedIds: {
            push: item.relatedId,
          },
        },
      })
    );
    👀 1
    a
    v
    • 3
    • 2
  • a

    AlexSPx

    06/30/2022, 8:06 PM
    Hello, I tried switching the database to mysql and got this error on the initial migration
    👀 1
    ✅ 1
    a
    v
    • 3
    • 6
  • a

    AlexSPx

    06/30/2022, 8:06 PM
    Copy code
    Error: Unknown column 'datetime_precision' in 'field list'
       0: migration_core::state::SchemaPush
                 at migration-engine\core\src\<http://state.rs:349|state.rs:349>
    ✅ 1
  • a

    AlexSPx

    06/30/2022, 8:06 PM
    Copy code
    generator client {
      provider = "prisma-client-js"
    }
    
    datasource db {
      provider = "mysql"
      url      = env("DATABASE_URL")
    }
    
    model Quote {
      id Int @id @default(autoincrement())
      quote String
      fromName String
      From From @relation(fields: [fromName], references: [fromName])
      topics Topic[]
    }
    
    model From {
      fromName String @id
    
      quotes Quote[]
    }
    
    model Topic {
      name String @id
      quotes Quote[]
    }
    ✅ 1
  • a

    AlexSPx

    06/30/2022, 8:06 PM
    And here is the schema
  • a

    AlexSPx

    06/30/2022, 8:07 PM
    The command I used was
    npx prisma migrate dev
    ✅ 1
    h
    n
    • 3
    • 4
  • s

    starlord btc

    06/30/2022, 9:03 PM
    Hello. My team decided to use Prisma as our ORM for our new set of services we're building using NestJS. It seemed to be going well, but we have a constant issue with the Prisma Schema being too restrictive. Basically we can't make any structural changes within our database without doing it via the Prisma schema. This is very strange to me as an experienced data engineer and DBA. It doesn't seem right that the ORM would dictate and control on this level. Are we missing something in terms of a config setting or similar that can relax the strictness?
    ✅ 1
    c
    t
    r
    • 4
    • 7
  • j

    Jean Moirano

    06/30/2022, 10:56 PM
    👋 Hello, team!
    👋 2
  • h

    Harshit Aneja

    07/01/2022, 2:04 AM
    Hey. I recently started using Prisma and love it so far but one thing I am unable to do is one way relationships. Multiple A can reference B but no reference Id in B. I saw open issues on github but they are unresolved as of now. Isn’t this a common enough use case? How does everyone else deal with it in the meanwhile?
    ✅ 1
    h
    • 2
    • 3
  • d

    Darryl Morley

    07/01/2022, 3:48 AM
    Hi, wondering if this is possible? Having an array of manufacturerID's, how can I exclude results by the id's in the array? Is this possible on a JSON field?
    Copy code
    {
                Manufacturer: {
                  path: ["manufacturerID"],
                  not: { in: ["28", "266", "213", "234"] },
                },
              },
    ✅ 1
    t
    • 2
    • 1
  • g

    Gonzalo iniguez

    07/01/2022, 6:40 AM
    Hi, its possible to db push on connected to new scheme on postgresql? i traying to do a multitenant but migration or sync to dbn in custom schema of pg cant connect
    ✅ 1
    t
    • 2
    • 1
  • g

    Gonzalo iniguez

    07/01/2022, 6:41 AM
    Copy code
    Example
  • g

    Gonzalo iniguez

    07/01/2022, 6:41 AM
    Copy code
    getClient(request: IRequest): PrismaClient {
        const tenantId = this.getTenantId(request);
        let client = this.clients[tenantId];
    
        // create and cache a new client when needed
        if (!client) {
          const databaseUrl = process.env.DATABASE_URL!.replace('public', tenantId);
    
          client = new PrismaClient({
            datasources: {
              db: {
                url: databaseUrl,
              },
            },
          });
    
          console.log('CLIENT', client);
    
          // setup prisma middlewares if any
          client.$use(PrismaLoggingMiddleware());
    
          this.clients[tenantId] = client;
        }
    
        return client;
      }
  • k

    Kay Khan

    07/01/2022, 9:27 AM
    Hi friends, i'm tryign to connect to mongodb and im getting the following error:
    Copy code
    PrismaClientInitializationError: The provided database string is invalid. Unable to parse URL. in database URL. Please refer to the documentation in <https://www.prisma.io/docs/reference/database-reference/connection-urls> for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.
        at /home/kay/checkpoint/nft-rarify/core/node_modules/@prisma/client/runtime/index.js:45403:20 {
      clientVersion: '4.0.0',
      errorCode: 'P1013'
    Copy code
    DATABASE_URL="<mongodb+srv://root:rootpassword@localhost:27017/demo-db>"
    any ideas why the database string is invalid?
    ✅ 1
    • 1
    • 1
  • k

    Kay Khan

    07/01/2022, 10:56 AM
    Hi, im using mongodb and i have the following model
    Copy code
    model Contract {
        id         String   @id @default(auto()) @map("_id") @db.ObjectId
        address    String   @unique
        active     Boolean
        last_fetch DateTime
    }
    I expect that if i insert a colletion with the same address it should fail? becuase of "@unique" But i am able to insert 2 contracts with the same address
    ✅ 1
    • 1
    • 1
  • l

    Liz Mowforth

    07/01/2022, 11:03 AM
    👉 prisma rainbow Using Prisma’s ORM in a professional project, but haven’t checked out our Data Platform yet? prisma rainbow👈 Then we’d love to hear from you! We’re looking for users who have experience working with our ORM in a professional project, and would be willing to take a first look around our Data Platform together with our team. Sessions last for max. 1 hour, and would require you to share your screen with us as we set up an example project together. You’ll be compensated for your time and will have the opportunity to provide feedback and ask any burning questions you might have about all things Prisma. ➡️ If you’d like to take part, just fill in our survey (it takes less than 2 minutes), and we’ll be in touch ⬅️
    👀 3
    prisma rainbow 3
    👋 3
  • t

    Théo Casner

    07/01/2022, 2:20 PM
    Hello everyone! I am forwarding this github Q/A using Nest and Prisma. https://github.com/prisma/prisma/discussions/14094 Thanks in advance 🙂
    ✅ 1
    a
    • 2
    • 1
  • d

    Drew

    07/01/2022, 3:46 PM
    Does anybody have any guidance on how to develop locally with Cloudflare’s wrangler without using the data proxy? Here’s the meat of the question… When developing with
    wrangler
    it uses miniflare which is a copy of cloudflare’s network locally. From everything I’ve been reading in the docs, in order to use the prisma client in cloudflare’s network you need to import it from the
    @prisma/client/edge
    . However, you can only use this using the data-proxy and I have a need to have multiple people developing and they can’t all be developing to one single development instance… each of them should have their own DB in Docker locally. At this point, i haven’t gotten it to work yet, but would love to hear if anybody else has. Thanks!
    ✅ 1
    n
    • 2
    • 7
  • e

    Ethan Phan

    07/01/2022, 5:47 PM
    Anyone has issues prisma generate just hang after upgrading to 4.0? I’m running this on nestjs. Unfortunately the hang doesn’t provide any error, it just hang.
    ✅ 1
    n
    • 2
    • 2
  • h

    hayes

    07/01/2022, 5:55 PM
    I have seen reports of this a few times with the pothos generator after upgrading to a new version of prisma, and even experienced it once myself. I haven't been able to reproduce the issue, but deleting node_modules seems to have resolved it for people reporting the issue
  • j

    Junior Miksza

    07/01/2022, 8:20 PM
    Hello everyone, i'm having issues unit testing prisma
    👀 1
    a
    v
    • 3
    • 2
  • j

    Junior Miksza

    07/01/2022, 8:21 PM
    i'm using the singleton example from the docs, but i doesnt work, the repository is not mocked and retrieve data from de database as normally
  • j

    Junior Miksza

    07/01/2022, 8:21 PM
    CreateUserUseCase.spec.ts
  • j

    Junior Miksza

    07/01/2022, 8:21 PM
    singleton.ts
  • p

    prisma chobo

    07/01/2022, 8:42 PM
    are we allowed to create a ttl index for mongodb using runcommandraw ??
    ✅ 1
    n
    • 2
    • 2
  • y

    Yerzhan

    07/02/2022, 5:43 AM
    hi all, how can I connect to GCP SQL PostgreSQL? this string doesn’t work:
    Copy code
    DATABASE_URL="postgresql://${GCP_SQL_USER}:${GCP_SQL_PASSWORD}@${GCP_SQL_HOST}:5432/${GCP_SQL_DB}
    ✅ 1
    t
    e
    • 3
    • 4
  • i

    Industrial

    07/02/2022, 11:56 AM
    Hi.
    Copy code
    'Error: \nInvalid `prisma.todo.create()` invocation:\n\n\n  Null constraint violation on the fields: ()\n    at RequestHandler.handleRequestError
    ✅ 1
    r
    • 2
    • 12
  • i

    Industrial

    07/02/2022, 11:57 AM
    It's showing an empty list of fields. When I google this I get 0 results with 0 fields.
  • s

    sazz

    07/02/2022, 3:42 PM
    sup guys, is prisma still sending the free stickers (that are on the site)? and there's any country limitation? just curious
    ✅ 1
    v
    • 2
    • 1
1...592593594...637Latest