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

    Andy

    07/02/2021, 6:42 PM
    looks like the above is a WSL2 only problem
  • s

    Sequential

    07/02/2021, 6:49 PM
    Any ideas how to make seeding work properly with a node server with “type”: “module”? When I change the seed file to seed.cjs, prisma doesn’t find it.
    r
    • 2
    • 1
  • g

    Gustavo Adolfo López

    07/02/2021, 9:11 PM
    Does anybody know how to provide the
    binaryTargets
    value as an environment variable? I’m deploying to AWS and setting the config to
    binaryTargets = ["native", "rhel-openssl-1.0.x"]
    works just fine, however I don’t want to include the
    native
    binary as it increases the lambda size considerably
  • m

    Marc

    07/02/2021, 11:03 PM
    Hi, I’m trying to use
    createMany
    , but it seems it couldn’t be found.
    Property 'createMany' does not exist on type.
    I’m using
    v2.26.0
    and sqlite. I’ve tried to put it into previewFeature, but I then get
    Please either remove the "createMany" feature flag or use any other database type that Prisma supports: postgres, mysql or sqlserver.
    Any idea?
    r
    • 2
    • 3
  • k

    khareta

    07/02/2021, 11:23 PM
    for an implicit many-many relationship, when connecting/disconnecting, does it remove the record from the join table? or how does it really behave?
    r
    • 2
    • 1
  • m

    Marc

    07/02/2021, 11:26 PM
    I’ve also updated our Prisma version from
    2.6.2
    to
    2.26.0
    and get now query times that are twice as slow. From 56ms to 121ms. Still sqlite. Any idea why there is a performance degradation between those versions?
    r
    • 2
    • 1
  • j

    Juan Raymundo Carrillo Jasso

    07/03/2021, 12:05 AM
    Can anybody help me? I want search with similarity, unaccent and lower, I can do it with this query (postgresql)
    Copy code
    SELECT
    	*
    FROM
    	public."City"
    WHERE
    	word_similarity(LOWER(unaccent(name)), LOWER(unaccent('mexico'))) > 0.3
    ORDER BY
    	name
    how would I do this with prisma? Note: I already have the plugins installed in the migrations
    r
    • 2
    • 2
  • c

    Chris Tsongas

    07/03/2021, 1:57 AM
    Is it possible to set a default for an array i.e.
    roles     Role[]     @default([Role.USER])
    ? I'm getting a syntax error.
    r
    • 2
    • 1
  • g

    Gustavo Adolfo López

    07/03/2021, 3:03 AM
    If anybody has any idea on how to set this properly, please let me know
    e
    r
    • 3
    • 2
  • y

    yoenho park

    07/03/2021, 5:23 AM
    hi !! our team uses the nexus-prisma-plugin and mainly uses the t.model and t.crud. we know that the prisma teamp is developing nexus-prisma, so what i’m wondering is.. 1. in nexus-prisma github page, t.model and t.crud status is long term. will it take long time to use this feature ? 2. if implemented, will it have the same functionality as the current one ? thank you for your effort 👍
    r
    • 2
    • 2
  • s

    SamTheFam

    07/03/2021, 12:06 PM
    hey!
  • r

    Ridhwaan Shakeel

    07/03/2021, 9:54 PM
    how do you reset one table? I am familiar with
    npx prisma migrate reset
    but not for dropping a single relation
    r
    • 2
    • 1
  • v

    Vinaya Sathyanarayana

    07/04/2021, 3:19 AM
    When are Geo data types expected in Prisma?
    r
    • 2
    • 1
  • e

    Eddy Nguyen

    07/04/2021, 7:18 AM
    Hello team, I’m using Prisma@2.26 at the moment and I’m trying to set an environment variable for
    client.binaryTargets
    . It looks like there’s this issue which has been addressed in this PR. However, I’m still having problems, and may be someone can help clarify how I’m supposed to use it. Here’s the related part in my schema:
    Copy code
    generator client {
      provider      = "prisma-client-js"
      binaryTargets = env("PRISMA_BINARY_TARGET") // I also tried to use `[env("PRISMA_BINARY_TARGET")]` but getting the same errors regardless
    }
    I have
    JSON.parse
    error when I try to do this:
    PRISMA_BINARY_TARGET=native prisma generate
    . Note that this was working in version 2.22 I think it’s because the parse function expects the env to be a JSON string 🤔 Anyways, running the following command works:
    PRISMA_BINARY_TARGET='[\"native\"]' prisma generate
    . To me, this is less ideal than the previous version because I didn’t know what to use until I looked at the source code. 😅 ( Maybe there are some documentation I’m missing ) Is this a bug? Happy to create an issue to follow up 🙂
    j
    • 2
    • 2
  • m

    Moh

    07/04/2021, 9:35 AM
    Hi all - quick question about Prisma types and typescript. Getting an error as I'm trying to type the Prisma response object with props as a number, but I get Prisma.Decimal | null is not compatible with number? What can I type this to?
    r
    • 2
    • 1
  • j

    jasci

    07/04/2021, 11:12 AM
    Hello everybody, I cannot set a field
    null
    if it’s defined as a list ? Like
    String[]
    ?
    r
    • 2
    • 3
  • g

    glekner

    07/04/2021, 1:15 PM
    can anyone help
    d
    • 2
    • 1
  • j

    Jared Fraser

    07/05/2021, 4:52 AM
    where's the best way to run a where on a deeply related query? Say if I have the relations A -> B -> C -> D. And I want to return A wth all relations of B, with all relations of C with a relation of D that
    type=item
    SQL i'm trying to mimic
    Copy code
    SELECT *
    FROM a
    LEFT JOIN b
    LEFT JOIN c
    LEFT JOIN d
    WHERE d.type='item'
    Copy code
    this.prisma.A.findMany({
      include: {
        B: {
          include: {
            C: {
              include: {
                d: {
                  where: {
                    type: 'item'
                  }
                }
              }
            }
          }
        }
      }
    })
    r
    • 2
    • 5
  • v

    Vladi Stevanovic

    07/05/2021, 9:06 AM
    New to Prisma? Are you just starting a new project / startup / side gig? Check out our new free course on how to build a fullstack app using Next.js, GraphQL, TypeScript, and Prisma, hosted by our DevRel Advocate Mahmoud Abdelwahab 🙌 https://www.prisma.io/blog/announcing-upcoming-course-8s41wdqrlgc7
    🙌 3
    prisma rainbow 5
    🇪🇬 1
    💯 3
  • j

    janpio

    07/05/2021, 10:50 AM
    prisma dark I could use your help: We have this small section in our documentation for community generators: https://www.prisma.io/docs/concepts/components/prisma-schema/generators#community-generators Some of them we are even testing in our end to end tests, to make sure everything keeps working: https://github.com/prisma/e2e-tests/tree/dev/community-generators Do you know of any we are missing here?
  • m

    Moshe

    07/05/2021, 11:24 AM
    I would like to change the name and location of the prisma folder. Currently it called
    prisma
    and it sits on the root folder of my nextjs project. I'd like to name it
    db
    and have it within the
    src
    folder. Is that possible? If so, how? Thanks 🙂
    👍 1
    j
    r
    • 3
    • 5
  • s

    Stephen

    07/05/2021, 12:43 PM
    Hey alll.... not sure if we've got a weird requirement here....... We are wanting to use Prisma to interface with our database... we've used introspect to generate our schema, and we can deploy that and that works.... However.... the database structure may be updated somewhere else, and deployed separately... meaning that any future deployments of our database interface would possibly break.. I assuming this is where migrate comes in, and we need to be using migrate for updating our database structure now?
    d
    • 2
    • 5
  • d

    Dev__

    07/05/2021, 12:51 PM
    hello, I have a raw query (postgres) here with an
    ORDER BY
    Copy code
    this.prisma.$queryRaw`
    	SELECT *
    	FROM "public"."OrderStatus"
    	INNER JOIN "public"."OrderStatusDescription" ON ("public"."OrderStatus"."id" = "public"."OrderStatusDescription"."orderStatusId")
    	WHERE "public"."OrderStatusDescription"."languageId" = ${languageId}
    	ORDER BY "public"."OrderStatusDescription"."name" DESC LIMIT ${pagination.take} OFFSET ${pagination.skip}
    `
    the moment I have a variable instead of hardcoded
    DESC
    the query doesnt work.
    Copy code
    ORDER BY "public"."OrderStatusDescription"."name" ${order.toUpperCase()} // order = 'asc' | 'desc'
    d
    r
    • 3
    • 21
  • l

    Lucas

    07/05/2021, 3:09 PM
    Hi everyone ! I’m upgrading to prisma2 but facing an issue. One app usecase involves my api making 3 consecutive queries on the same table (with different WHERE params) in my postgres db. If repeating the operation, 2 or 3 times in a row, one database process blows up the cpu usage. I’ve tried to tune the _connection_limit_ param (setting it to 1) with no luck. Could this be related to the query lock mode ? I’m a bit confused by the pg_locks output. Have you already faced something similar ? Thanks prisma team for the great work !
    j
    • 2
    • 13
  • d

    David

    07/05/2021, 3:13 PM
    Hey folks, Would love some help with this non-descriptive error message I'm getting (see screenshot). I call
    prisma.query.create
    as follows (where queryService(data) is just calling
    prisma.create({data})
    ):
    Copy code
    const query = await this.queryService.createQuery({
                genome: s.slice(0,10),
                type: 'Auto',
                description: form.description,
                user: {
                    connect: {id: user.id}
                }
            });
    This produces the error pretty much no matter what I do. I logged the object I'm trying to insert, seems fine... so I don't see what the problem is. The relevant model is:
    Copy code
    model Query {
      id String @id @default(uuid())
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
    
      user User @relation(fields: [userId], references: [id])
      userId String
    
      genome String
      type GenomeType @default(Auto)
      description String?
      result String?
    }
    Would appreciate any help!
    g
    j
    • 3
    • 16
  • g

    Giorgio Delgado

    07/05/2021, 4:41 PM
    I want to modify data from a prisma query before users receive the data through the various
    prisma.modelName.queryName
    methods - but after the query successfully complets. As a contrived example, let’s say I have a model like this:
    Copy code
    model Person {
       id @id @default(cuid())
    
       first_name String
       
       gender Gender
    }
    Now what if I want to modify
    first_name
    after fetching it from the database to include
    Mr
    or
    Ms
    . so that if i do:
    Copy code
    const bob = await prisma.person.findFirst({
      where: { id: someCuid }
    })
    Then
    bob.first_name
    should say
    Mr. bob
    or something like that. I know that Prisma has middleware using
    prisma.$use
    but I don’t quite understand how i’d go about doing this since this is a post-query modification … as opposed to a pre-query modification that I see examples of in the docs
    d
    j
    • 3
    • 6
  • b

    Bruno Casado

    07/05/2021, 8:36 PM
    hello guys
  • b

    Bruno Casado

    07/05/2021, 8:36 PM
    can i use native db functions like TRIM from pgsql?
  • b

    Bruno Casado

    07/05/2021, 8:37 PM
    like: select field from table where trim(fieldB) = 'whatever '
    r
    • 2
    • 2
  • a

    Ahmar Suhail

    07/06/2021, 8:21 AM
    Hey, I had a question around best practice. So we have a few different services that interact with our DB using prisma. We haven't yet started using
    prisma migrate
    and currently we use sequelize migrations to make changes to our DB. So whenever we need to make a change to our DB our process is: • Run sequelize migrate • run prisma introspect manually on all our services that use prisma & commit I am just wondering if there's a better way to do this? (eg: Should we be generating our prisma schemas on build time?)
    j
    • 2
    • 3
1...453454455...637Latest