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

    Neo Lambada

    11/18/2021, 11:50 AM
    this is my current end result
  • j

    James

    11/18/2021, 12:46 PM
    Hi all, is it possible to have a relation against a string column that looks like this:
    1,2,3
    ?
    r
    • 2
    • 4
  • j

    Julien Goux

    11/18/2021, 2:28 PM
    Hello team! Is this issue planned soon : https://github.com/prisma/prisma/issues/10183 ?
  • j

    Julien Goux

    11/18/2021, 2:28 PM
    We had to change the way we launch our tests because of it
  • a

    Adrian

    11/18/2021, 3:28 PM
    Hi everyone. Does anyone know if there some kind of tool to autogenerate a Rest API or GraphQL API from Prisma? Similar to Hasura
    j
    • 2
    • 1
  • l

    Lars Ivar Igesund

    11/18/2021, 3:33 PM
    @Adrian Nexus with some plugins did that for Prisma 1, not entirely sure what the status is for the newer versions (I know some tooling was slated for rewrite)
  • s

    sctnightcore

    11/18/2021, 4:15 PM
    Hello. Do u have an example about this ? . https://github.com/prisma/prisma-client-js/issues/679
    r
    • 2
    • 1
  • k

    Kelly Copley

    11/18/2021, 4:39 PM
    Has anyone here setup Next Auth with the Prisma adapter using JWT instead of standard sessions? With standard sessions I get a user supplied to Next Auth's session callback, but when I set it up to use JWT it stops supplying the user to that callback.
  • a

    Andy Kimball

    11/18/2021, 4:50 PM
    Hi all, glad to be part of this community. I joined b/c I've been doing a lot of work on serverless at CockroachDB, and want to understand more deeply how Prisma is approaching serverless.
  • p

    Peter Takacs

    11/18/2021, 4:53 PM
    Hello, Is there an example out there to using fragments with Prisma Client 3.x. Can’t really find yet.
    b
    • 2
    • 4
  • d

    Daniel Norman

    11/18/2021, 5:01 PM
    We’re live!

    https://www.youtube.com/watch?v=fAcHR5dqt_4▾

    Be sure to join us in the #prismaserverless
    🙌 3
  • e

    Elijah Rosier

    11/18/2021, 5:04 PM
    Has anyone deploying via serverless framework using serverless-typescript-plugin managed to get it deploying successfully? I have the following in my
    serverless.yml
    Copy code
    package:
      individually: true
      patterns:
        - '!node_modules/@prisma/engines/prisma-fmt-debian-*'
        - '!node_modules/@prisma/engines/introspection-engine-*'
        - '!node_modules/@prisma/engines/libquery_engine-debian-*'
        - '!node_modules/@prisma/engines/migration-engine-*'
        - '!node_modules/typescript/**'
        - '!node_modules/.prisma/client/query-engine-*'
        - '!node_modules/.prisma/client/libquery_engine-*'
        - 'node_modules/.prisma/client/libquery_engine-rhel-*'
     which correctly keeps only the
    libquery_engine-rhel-openssl-1.0.x.so.node
    binary
    Copy code
    # /node_modules/@prisma/engines
    total 51M
    drwxr-xr-x 4 root root 4.0K Nov 18 16:28 .
    drwxr-xr-x 5 root root 4.0K Nov 18 16:28 ..
    -rw-r--r-- 1 root root  537 Jan  1  1980 README.md
    drwxr-xr-x 2 root root 4.0K Nov 18 16:28 dist
    drwxr-xr-x 2 root root 4.0K Nov 18 16:28 download
    -rwxr-xr-x 1 root root  42M Jan  1  1980 libquery_engine-rhel-openssl-1.0.x.so.node
    -rw-r--r-- 1 root root  774 Jan  1  1980 package.json
    -rwxr-xr-x 1 root root 8.6M Jan  1  1980 prisma-fmt-rhel-openssl-1.0.x
    However, once deployed and I attempt to access the endpoint I receive the following error in CloudWatch:
    Copy code
    ERROR	PrismaClientInitializationError: 
    Invalid `prisma.executeRaw()` invocation:
    
    
      Query engine library for current platform "rhel-openssl-1.0.x" could not be found.
    You incorrectly pinned it to rhel-openssl-1.0.x
    
    This probably happens, because you built Prisma Client on a different platform.
    (Prisma Client looked in "/var/task/node_modules/@prisma/client/runtime/libquery_engine-rhel-openssl-1.0.x.so.node")
    
    Searched Locations:
    
      /var/task/node_modules/.prisma/client
      /actions-runner/_work/listener-suite/listener-suite/backend/node_modules/@prisma/client
      /var/task/node_modules/@prisma/client
      /var/task/node_modules/.prisma/client
      /var/task/node_modules/.prisma/client
      /tmp/prisma-engines
      /var/task/node_modules/.prisma/client
    
    
    To solve this problem, add the platform "rhel-openssl-1.0.x" to the "binaryTargets" attribute in the "generator" block in the "schema.prisma" file:
    generator client {
      provider      = "prisma-client-js"
      binaryTargets = ["native"]
    }
    
    Then run "prisma generate" for your changes to take effect.
    Read more about deploying Prisma Client: <https://pris.ly/d/client-generator>
        at cb (/var/task/node_modules/@prisma/client/runtime/index.js:38508:17)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async Promise.all (index 0) {
      clientVersion: '3.4.2',
      errorCode: undefined
    }
    Is there a way to define the search path, or is there something else I'm doing completely wrong. Apologies for my ignorance, I'm new to using Prisma. Also another note, somehow our zipped lambda is 80MB, even with all of my custom excludes in the
    serverless.yml
    (is this normal with Prisma in AWS?)
    n
    • 2
    • 2
  • m

    Muzaffar Hussain

    11/18/2021, 5:31 PM
    Can We use Prisma with JavaScript ,HTML & CSS? If I store any data from website, How to use Prisma in this..
    r
    • 2
    • 1
  • u

    user

    11/18/2021, 5:34 PM
    Keynote - Prisma Serverless Conference

    https://www.youtube.com/watch?v=dPfdJyLvS5o▾

    Data access comes with challenges that require more than an ORM, especially when working in a serverless environment. At Prisma, our vision is to enable any team to have its own reliable and scalable data access layer, while also making it easier to move fast and iterate quickly. In this video, you will learn how the Prisma Data Platform can help use more traditional databases in your serverless applications. Try the Prisma Data Plarform https://www.prisma.io/dataplatform 00:00 Introduction 02:35 Prisma Data Platform 07:00 Data Proxy 12:23 Quick summary 13:38 Preview Deployments 20:44 Data Projections 26:46 Conclusion
  • j

    joao.santos

    11/18/2021, 6:51 PM
    Hi guys Im doing this and cant connect to my mssql server. SQL Browser is enabled... `DATABASE_URL="sqlserver://localhost\sqlexpress;database=nschat;integratedSecurity=true;trustServerCertificate=true;"`` Error: P1012: error: Error validating: This line is not a valid definition within a datasource. --> schema.prisma:4 | 3 | provider = "sqlserver" 4 | url = "sqlserver://localhost\sqlexpress;database=nschat;integratedSecurity=true;trustServerCertificate=true;" 5 | } | I followed this: https://www.prisma.io/docs/concepts/database-connectors/sql-server
  • s

    Sabin Adams

    11/18/2021, 7:24 PM
    Does anyone have a workaround for working with multiple schemas within a DB?
    j
    • 2
    • 3
  • p

    Pierre Ortega

    11/18/2021, 7:29 PM
    I’ve been using prisma on a project with multiple databases, and I’m just generating the client in different folders
    👍 1
  • p

    Pierre Ortega

    11/18/2021, 7:30 PM
    Copy code
    generator client {
      provider        = "prisma-client-js"
      output          = "./db1/__generated__/"
    }
    
    ... another schema file ...
    
    generator client {
      provider        = "prisma-client-js"
      output          = "./db2/__generated__/"
    }
  • p

    Pierre Ortega

    11/18/2021, 7:31 PM
    then you import from there:
    Copy code
    import { PrismaClient as DB1PrismaClient } from './db1/__generated__';
    import { PrismaClient as DB2PrismaClient } from './db2/__generated__';
  • s

    Sabin Adams

    11/18/2021, 7:48 PM
    Gotcha, I do the same. But what I'm referring to is a single DB with multiple schemas within it that group up tables into logical groups
  • s

    Sabin Adams

    11/18/2021, 7:50 PM
    For example, these queries:
    Copy code
    SELECT * FROM dbo.Contacts
    SELECT * FROM geo.Locations
    I have two schemas here,
    dbo
    and
    geo
    . I'm trying to find out if there's a way to access these via prisma without having to generate a completely different client just for the geo schema
  • n

    Nathaniel Babalola

    11/18/2021, 10:04 PM
    Can anyone help me convert this code snippet to JavaScript.
    Copy code
    import { PrismaClient } from '@prisma/client';
    import { DMMFClass } from '@prisma/client/runtime';
    
    const prisma = new PrismaClient();
    const dmmf = ((prisma as any)._dmmf as DMMFClass);
    w
    r
    • 3
    • 3
  • d

    Danny

    11/18/2021, 11:00 PM
    What's the difference between importing types these two ways? Which one should I prefer? Tried finding some info on this in the docs but didn't see anything explicitly referencing how to import a basic model type - if there is a page or guide that I'm overlooking I would love to read it over!
    Copy code
    import type { Group } from '@prisma/client';
    import type { Group } from 'prisma/prisma-client';
    c
    • 2
    • 1
  • k

    Kervin Vasquez

    11/19/2021, 7:36 AM
    Hello everyone, just looking for some guidance regarding using Prisma + Nexus connection type, https://nexusjs.org/docs/plugins/connection. By any chance does anyone know how to correctly implement the resolver of a connection type? For example for a
    users
    should I just be returning ctx.db.users.findMany() ? Could this approach have repercussions in performance given that it would be fetching all records ? I'm just not sure what
    return ctx.users.resolveForConnection(root, args, ctx, info)
    means in the example.
    k
    • 2
    • 2
  • k

    Kay Khan

    11/19/2021, 11:03 AM
    Hi friends i have 4 tables,
    person
    game
    games_played
    and
    images
    The query below finds all the games a person has played and within the
    game
    table their is a
    cover_id
    which is a FK to the
    images
    table. When i generate the prisma sdk, you can see that this relationship between
    game
    and
    images
    is identified with the following name
    image_game_cover_idToimage
    Copy code
    image_game_cover_idToimage  image?                    @relation("game_cover_idToimage", fields: [cover_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_c529e54ccb5e986f6e8bc52f169b42fe")
    can someone explain to me how this naming convention is chosen here and if its possible to give this a different name.
    Copy code
    const result = await db.games_played.findMany({
      where: { entity_id: person.id },
      distinct: ["game_id"],
      include: { game: { include: { image_game_cover_idToimage: true } } },
    });
    I guess the kind of solution im looking for is something like;
    Copy code
    from: { include: { image_game_cover_idToimage: true } }
    
    to: { include: { image_game_cover_idToimage: { as: "image" } } }
    k
    • 2
    • 4
  • m

    Merlin G

    11/19/2021, 1:54 PM
    Seeing an issue where prisma works in serverless next.js API endpoints, but when we try to use it from
    getServerSideProps
    we get an error when
    next build
    is run with `target: serverless`:
    Copy code
    Error: ENOENT: no such file or directory, open '/home/runner/work/<my path>/.next/serverless/chunks/schema.prisma
    Has anyone seen anything like this? It seems particularly tricky to debug given that it only happens when prisma client calls are added to
    getServerSideProps
    • 1
    • 1
  • s

    Sergey

    11/19/2021, 3:58 PM
    Hi @all Nice to meet you here
    👋 1
    🖐️ 1
  • t

    timothykrell

    11/19/2021, 6:13 PM
    Hey. I have a model that has two relations. Both relations have a
    score
    field. I want to sort the model by the average of the two
    score
    fields on its relations. Is this possible with Prisma client, or do I have to do a raw sql?
    r
    • 2
    • 1
  • a

    Avi Fatal

    11/19/2021, 9:20 PM
    Hi, Im running node 14. After clearing the cache, re-installing the node_modules and running generate I get the error
    Copy code
    > nx run auth:serve 
    chunk (runtime: main) main.js (main) 1.71 MiB [entry] [rendered]
    
    WARNING in ./node_modules/@prisma/client/runtime/index.js 14988:18-45
    Module not found: Error: Can't resolve 'encoding' in '/work/tokenct/apps/auth/node_modules/@prisma/client/runtime'
    
    ERROR in ./node_modules/@prisma/client/runtime/index.js 27212:17-40
    Module not found: Error: Can't resolve '_http_common' in '/work/tokenct/apps/auth/node_modules/@prisma/client/runtime'
    
    webpack compiled with 1 error and 1 warning (e96b0171bcc71130)
    There was an error with the build. See above.
    /work/tokenct/dist/apps/auth/main.js was not restarted.
    The webpack thing did not help... I have downgraded from 16 because of this issue. Anyone can help? Thanks
  • a

    Ahmet

    11/20/2021, 12:17 AM
    It should be understood as the set of changes to get from the expected schema to the actual schema.
    [-] Removed tables
    - Message
    `[*] Changed the
    Message
    table`
    [-] Removed foreign key on columns (instanceWorkerId)
    ✔ We need to reset the PostgreSQL database "wmd_db" at "host:port".
    Do you want to continue? All data will be lost. … no
    I accidentally deleted the Message table in the prod environment. I’m worried about migrating. I know that if I say yes, my data will be lost. What should I do? I couldn’t find enough information in the documentation 😞
1...509510511...637Latest