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

    Yaakov

    10/13/2021, 10:43 PM
    The following example from https://www.prisma.io/express does not work due to my
    id
    field being an integer. I get the following error:
    PrismaClientValidationError: Argument id: Got invalid value '1' on prisma.updateOnePost. Provided String, expected Int.
    Copy code
    app.put('/publish/:id', async (req, res) => {
      const { id } = req.params
      const post = await prisma.post.update({
        where: { id },
        data: { published: true },
      })
      res.json(post)
    })
    Is there anyway to run this without calling
    parseInt(id)
    ?
    p
    d
    r
    • 4
    • 6
  • y

    YeonHoPark

    10/14/2021, 2:04 AM
    hi !! I wonder why the type inference of User type is different in the two case below.
    👀 1
    r
    • 2
    • 4
  • u

    user

    10/14/2021, 6:45 AM
    Prisma Meetup #8: Victor Iris Del Prado - Boosting development with Prisma & GraphQL

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

    In this talk, we will discover how a service evolved into one of the most important features of a pharmaceutical system, using the benefits of Prisma and Apollo Server. Victor is a Sr. FullStack engineer at DigitalOnUs by Tech Mahindra, where he helps lead the development of a project in the pharmaceutics industry. He loves working with Typescript & Go and is one of the Prisma Ambassadors. Follow Victor on Twitter: https://twitter.com/victoriris_xyz ✨ Join our Prisma Meetup group here: https://www.meetup.com/Berlin-Prisma-Meetup/ Next: 👉 Check Next video: Full Stack Jamstack Fun -

    https://youtu.be/II3a0WyIhXs▾

  • g

    Garrick Chippendale

    10/14/2021, 8:25 AM
    Copy code
    Error: db error: ERROR: syntax error at or near ","
       0: sql_migration_connector::sql_database_step_applier::apply_migration
                 at migration-engine\connectors\sql-migration-connector\src\<http://sql_database_step_applier.rs:11|sql_database_step_applier.rs:11>
       1: migration_core::api::SchemaPush
                 at migration-engine\core\src\<http://api.rs:184|api.rs:184>
    i keep getting this error from
    npx prisma db push
    , and i really cant fix it or figure out whats wrong. it started happening when prisma was telling me It will have to drop my data to push my db, because I changed my enum (but the enum is identical to whats in the database except with a different name), so I simply went into the database and manually renamed the enum to match what it is in my prisma schema, so that prisma wouldnt have to drop my data. the only 2 outcomes i can get are prisma saying it has to drop my data, or the above error. anything i should try/do?
    r
    • 2
    • 1
  • h

    Halvor

    10/14/2021, 8:37 AM
    How can i make an aggregate sum function return 0 if not records instead of “null” ?
    r
    • 2
    • 4
  • j

    Jemin Kothari

    10/14/2021, 8:50 AM
    Hello @Ryan I created enum type
    Copy code
    enum Test {
      Open
      Converted
      Junk
    }
    r
    r
    • 3
    • 11
  • c

    Codker

    10/14/2021, 10:30 AM
    hello everyone! I’m considering using Prisma for an internal framework, but one of my requirements is to split the framework core features in separate modules. For example we must have a “user” module that provides the GraphQL queries/mutations/subscriptions and a service layer that wraps the orm.
  • c

    Codker

    10/14/2021, 10:30 AM
    I have come up with two ideas: - split Prisma schemas between modules, joining them in the schema.prisma in the app using the framework - generate a unique Prisma client for each module, export the typings and merge them with the app’s Prisma client The other problem that I must think about is how to manage migrations for the framework’s modules. With the first solution, all migrations are in the app, as usual. With the second I think that framework’s migrations should be executed with a custom solution, complex but keeps things modularized. Has anyone done that kind of schema splitting? Suggestions?
    r
    • 2
    • 4
  • d

    Dev__

    10/14/2021, 12:21 PM
    hello, is there a way to search in concatinated fields with prisma?
    r
    • 2
    • 1
  • j

    jcardona

    10/14/2021, 3:15 PM
    Hi, I get the following error when I run a unit test with jest (nestjs and prisma). TypeError: this.prismaService.$transaction is not a function. Does anyone know how I can fix this error in my jest code? I appreciate your help
  • j

    jcardona

    10/14/2021, 3:15 PM
    Part of my code in jest: const module = await Test.createTestingModule({             providers: [                 RemisionesService, PedidosBodegasService, BodegasService, PedidosSucursalesService, FabricantesService, EstantesService, LineaBodegasService, ProductosService, SucursalesService, PrismaService,                 {                     provide: PrismaService,                     useFactory: () => ({                         remisiones: {                             findFirst: jest.fn(),                             findMany: jest.fn(),                             findUnique: jest.fn(() => { return { producto: { cantidad_presentacion: 10 } } }),                             create: jest.fn(),                             update: jest.fn(() => {                                 return {                                     producto: { cantidad_presentacion: 10 },                                     data: [{                                         RemisionesPedidosBodegasProductosSec: { create: [{ pedido_sucursal_producto_id: 3, fraccion: 2, cantidad: 20, precio: 55.10 },] }                                     }]                                 }                             }),                             delete: jest.fn(),                         },                         pedidosBodegas: {                             findUnique: jest.fn(() => {                                 return { pedido_bodega_id: 1 }                             }),                         },                     }),                 },             ],         }).compile();
    j
    • 2
    • 2
  • a

    Alex Vilchis

    10/14/2021, 6:02 PM
    Hello, everyone 👋 Has anyone have project using npm 7 workspaces with a prisma + nexus package? I have noticed that prisma is generating the client inside the package's local
    node_modules
    directory, instead of using the root package
    node_modules
    (where nexus-plugin-prisma looks for them) 🤔
    m
    • 2
    • 3
  • a

    Augustus Chang

    10/14/2021, 8:20 PM
    https://prisma.slack.com/archives/CA491RJH0/p1633968776459100 <-- any recommendations @Ryan? Thanks 😄
    r
    • 2
    • 1
  • s

    Swapnil Tandel

    10/14/2021, 8:32 PM
    hello  I would like to get help on following things. How can i get raw query generated using PRISMA functions? How can we setup PRISMA 1 server as an autoscale ECS, can anybody help us on that? we are okay to have paid technical help as well.
  • i

    Ibad Shaikh

    10/15/2021, 6:03 AM
    Hi 👋 When Im running npx prisma generate , it throws an error : PS E:\Work> npx prisma generate Environment variables loaded from .env Prisma schema loaded from prisma\schema.prisma Error: _*Error: EBUSY: resource busy or locked, copyfile 'E:\Work\node_modules\prisma\query_engine-windows.dll.node' -> 'E:\Work\node_modules\.prisma\client\query_engine-windows.dll.node'*_ I am unable to figure out which resource is busy or locked. Please guide 😊
    r
    • 2
    • 1
  • c

    Chris Tsongas

    10/15/2021, 6:17 AM
    Hi, trying to deploy to Heroku. I successfully ran migrations using
    heroku run npx prisma migrate deploy
    however when I try to seed the database using
    heroku run npx prisma db seed
    it borks with the following error:
    Copy code
    Running seed command `ts-node prisma/seed/index.ts` ...
    
    An error occured while running the seed command:
    Error: Command failed with ENOENT: ts-node prisma/seed/index.ts
    spawn ts-node ENOENT
    r
    c
    l
    • 4
    • 19
  • m

    Mykyta Machekhin

    10/15/2021, 9:14 AM
    Hi guys, for some reason I cannot import utility types from prisma, although it are there. What could be the reason?
    r
    • 2
    • 2
  • m

    Matt Lawson

    10/15/2021, 9:21 AM
    Hello 🙂 How does Prisma make money? I was looking for pricing on the main website and could not find anything.
    n
    • 2
    • 1
  • m

    Mischa

    10/15/2021, 11:41 AM
    any way to change prisma client logging configuration at runtime? I want to enable query logging for a prisma client constructed by a plugin (prisma-appsync)
    r
    • 2
    • 4
  • n

    Nathaniel Babalola

    10/15/2021, 1:23 PM
    I just did an
    npx prisma migrate dev
    , any reason why Prisma is converting
    table.column_unique
    to
    table.column_key
    ?
    r
    j
    • 3
    • 6
  • m

    Mykyta Machekhin

    10/15/2021, 4:00 PM
    Why is there no nested createMany? Is there any limitation in the implementation? This may help to improve the purity of the rates of complex data structures
    l
    n
    • 3
    • 2
  • w

    William Chantry

    10/15/2021, 4:06 PM
    has anyone seen connection timeouts using prisma with nestjs? we followed the connection pool guidelines for running on our kubernetes cluster but our prod environment has gone down twice now 🙃
  • d

    Danny

    10/15/2021, 6:30 PM
    Hey all, just a general question about prisma migrations and seeding. When doing development, say I make a change to a model that requires making a change to my seed script due to the model change. I can run
    prisma db push
    to "push" the changes to the database without actually creating a new migration, but if I run
    prisma db seed
    , it doesn't reset the database in the same way that
    prisma migrate reset
    would do - it would just run the seed scripts twice, potentially duplicating data, etc. Is there a suggested workflow for prototyping seed changes without needing to either (a)
    prisma migrate reset
    or (b) drop all the records across all tables in the seed script?
    r
    • 2
    • 5
  • p

    Pierre Ortega

    10/15/2021, 8:33 PM
    I have been running into this issue when trying to use `queryRaw`:
    Copy code
    Your raw query had an incorrect number of parameters. Expected: `0`, actual: `2`
    But my query does not use any parameters, I think.
    Copy code
    const history = await db.$queryRaw<HistoryData>`
      SELECT
        a.day,
        s."value" as slp,
        s."value"  - lag(s."value" ) over (order by a.day) as increase
      FROM (
        SELECT
          DISTINCT d.day,
          max(s. "date") OVER (ORDER BY d.day) AS effective_date
        FROM (SELECT generate_series('2021-10-01'::date, now()::date, '1d')::date) d (day)
        LEFT JOIN "WalletsHistory" s ON DATE(s.date) = d.day AND s.wallet_id = '${wallet.id}'
      ) a
      INNER JOIN "WalletsHistory" s ON s.date = a.effective_date
        AND s.wallet_id = '${wallet.id}'
      ORDER BY
        a.day;
      `;
    s
    • 2
    • 3
  • g

    Garrick Chippendale

    10/15/2021, 11:35 PM
    Does prisma support generated columns (postgres)? for example, if i have a
    user
    model which has
    wallet_balance(int)
    and `bank_balance(int)`and I want to have a generated column saying
    total_balance = wallet_balance + bank_balance
    ?
    r
    • 2
    • 1
  • t

    Thanh-Long PHAM

    10/15/2021, 11:52 PM
    Hello i’ve been trying to link my Mysql database i’ve got on OVH to next.js via prisma but it doesn’t seem to find it, could someone help me ?
  • u

    user

    10/16/2021, 9:14 AM
    Connect Dev Africa #2: Anthony Kiplimo - Elarian - A Tale of Communication & Data

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

    Anthony showcases Elarian, a customer engagement framework for building robust applications that’s reactive and has low infrastructure needs. ✨ Join our Prisma Meetup group here: https://www.meetup.com/connect-dev-africa/ Follow Anthony Kiplimo on Twitter: https://twitter.com/AnthonyLimo Next: 👉 Check Previous video: Building Accessible Design Systems with React -

    https://youtu.be/lOogsGx5XoY▾

  • s

    Subho

    10/16/2021, 12:55 PM
    createMany is not available for Prisma entities.
    Property 'createMany' does not exist on type 'SampleEntityDelegate<RejectOnNotFound | RejectPerOperation>
    From package.json:
    "prisma": "^3.2.1",
    "@prisma/client": "^3.2.1",
    r
    • 2
    • 1
  • l

    Logan

    10/16/2021, 3:15 PM
    Copy code
    [
      'guildID1': {
        messageTotal: 1,
        inviteTotal: 1,
        memberTotal: 1,
        joinTotal: 1,
        leaveTotal: 1
      },
      'guildID2': {
        messageTotal: 1,
        inviteTotal: 2,
        memberTotal: 3,
        joinTotal: 4,
        leaveTotal: 5
      }
    ]
    Hey, just wondering how I can use
    createMany
    method to insert the data above? the table looks like:
    r
    • 2
    • 1
  • l

    Logan

    10/16/2021, 3:16 PM
    for each of the different
    guildids
    it should be a new row.
1...494495496...637Latest