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

    Kanav Raina

    02/24/2022, 11:34 AM
    hi every one kindly tell me how to apply offset and limit to a groupby in prisma
    e
    • 2
    • 3
  • a

    Alex Masinde

    02/24/2022, 11:45 AM
    Hi guys, I am trying to deploy an Express, Prisma, and MySQL backend to AWS EC2, but there is very little guidance in the docs. Does anyone has a resource or a guide that I could use?
  • h

    hj yuiyui

    02/24/2022, 1:03 PM
    Hi guys i have this:
    Copy code
    export async function getUserEventsQuery(website_id, start_at, end_at, day, monthClean, weekClean, yearClean) {
      return runQuery(
        prisma.$queryRaw`
        SELECT g.groupevent_id, g.groupevent_name, g.objectif, g.periode_objectif, g.event_type, g.event_value, COUNT(e.groupevent_id) AS resultat,
        CASE  g.periode_objectif
            WHEN 'Jour' THEN ((COUNT(e.groupevent_id) / ${day}) * 100 /g.objectif)
            WHEN 'Mois' THEN ((COUNT(e.groupevent_id) /${monthClean}) *100/g.objectif)
            WHEN 'Semaine' THEN ((COUNT(e.groupevent_id) /${weekClean}) *100/g.objectif)
            WHEN 'Année' THEN ((COUNT(e.groupevent_id) /${yearClean}) *100/g.objectif)
        END as rate
        FROM groupevent as g 
           LEFT JOIN event e
              ON g.groupevent_id = e.groupevent_id
                 AND e.created_at between ${start_at} AND ${end_at}
        WHERE g.website_id=${website_id} 
        GROUP by g.groupevent_id
        ORDER BY  resultat DESC ;
        `,
      );
      and it returns me Invalid
    prisma.queryRaw()
    invocation: Raw query failed. Code:
    22P03
    . Message:
    db error: ERROR: incorrect binary data format in bind parameter 2
    what does it means ? dayClean, monthClean are defined h`ere const numberOfDays = endDate - startDate`    
    const day = Math.ceil(numberOfDays / 86400000)
       
    const week = numberOfDays / 604800000
       
    const weekClean = parseFloat(week.toFixed(3))
       
    const month = numberOfDays / 2592000000
       
    const monthClean = parseFloat(month.toFixed(3))
       
    const year = numberOfDays / 31556952000
       
    const yearClean = parseFloat(year.toFixed(3))
       
    const events = await getUserEventsQuery(parseInt(website_id), startDate, endDate, day, weekClean, monthClean, yearClean);
    I'm stuck hard for like 2h on this shit, i dont see why its incorrect data (monthClean etc are type number)
  • t

    Torrino

    02/24/2022, 1:47 PM
    Good day. Quick question. Can you not limit the number of deletions on
    deleteMany()
    n
    • 2
    • 2
  • a

    Alfred Noland

    02/24/2022, 3:15 PM
    Hi, how should you go around using Prisma as multi-tentant source with different microservices in Node.js? For example we have one location database and we have one app for transactinal purposes and one for content. But we want to use the same location db in both apps.
    l
    i
    • 3
    • 8
  • a

    Alfred Noland

    02/24/2022, 4:15 PM
    For someone with experience withinn described setup, we would like to hire for a few hours for a good hourly rate.
  • d

    devon lo

    02/24/2022, 4:30 PM
    is it prisma worth learning?
    i
    • 2
    • 1
  • j

    Jonas Rothmann

    02/24/2022, 4:46 PM
    Anyone aware of the best practice for searching across say 10 fields? Feels weird to write a really long where query
    a
    • 2
    • 3
  • e

    Ethan Cohen

    02/24/2022, 7:43 PM
    does prisma support custom annotations in the schema?
    n
    • 2
    • 3
  • t

    Tyler Clendenin

    02/24/2022, 7:51 PM
    does anyone have any example, package or recipe to add New Relic APM logging to Prisma in some way. I know Prisma has it's shortcomings on observability, but I'd like to at least get some data into an APM. afaik the only thing to do is to add a $on('query', ... ) event listener and do the logging in there. but I can't figure out how to get that data to be a database transaction in New Relic
  • p

    PanMan

    02/24/2022, 10:02 PM
    Does anybody understand this error? It seems I’m the first ever getting it (no github issues or anything):
    Conversion from collation utf8_general_ci into utf8mb4_general_ci impossible for parameter
    - I imported and exported the db (migrated to a new host). I’m not explicitly setting the charset anywhere, nor can I in Prisma, right?
  • p

    PanMan

    02/24/2022, 10:05 PM
    the table seems to have the same collation, but the connection does not?!
  • v

    Vyrek XD

    02/24/2022, 10:14 PM
    is there a way to get the ping of the DB using prisma and mongodb?
  • p

    PanMan

    02/24/2022, 11:28 PM
    Is there a way to hook into a connection (from a pool) connecting?
  • b

    Boo

    02/25/2022, 1:38 AM
    Are we able to order by a boolean in prisma? like sort boolean
    true
    first and then
    false
    last
    n
    • 2
    • 1
  • s

    Stephen Jensen

    02/25/2022, 2:05 AM
    Hey everyone- Does anyone know how to change a model name without having to drop the table? I'm migrating to next-auth 4 and they have a change in the schema where it removes
    @@map(users)
    from the
    model User
    which will change the database table from
    users
    to
    User
    . When I run the migration it is saying that it will drop the user's database which I don't want to do 🙂
    prisma green 1
    • 1
    • 1
  • m

    Marvin

    02/25/2022, 11:52 AM
    Hi! Embedded documents are mongodb only, right?
    n
    • 2
    • 2
  • h

    hj yuiyui

    02/25/2022, 12:38 PM
    Hi guys can someone help me to translate this thing to prisma orm thing ?
  • h

    hj yuiyui

    02/25/2022, 12:39 PM
    Copy code
    export async function getUserEventsQuery(
      website_id,
      start_at,
      end_at,
      day,
      monthClean,
      weekClean,
      yearClean,
    ) {
      console.log(typeof monthClean);
      return runQuery(
        prisma.$queryRaw`
        SELECT g.groupevent_id, g.groupevent_name, g.objectif, g.periode_objectif, g.event_type, g.event_value, COUNT(e.groupevent_id) AS resultat,
        CASE  g.periode_objectif
             WHEN 'Jour' THEN((COUNT(e.groupevent_id) / ${day}) * 100 / g.objectif)
             WHEN 'Mois' THEN((COUNT(e.groupevent_id) / ${monthClean}) * 100 / g.objectif)
             WHEN 'Semaine' THEN((COUNT(e.groupevent_id) / ${weekClean}) * 100 / g.objectif)
            WHEN 'Année' THEN((COUNT(e.groupevent_id) / ${yearClean}) * 100 / g.objectif)
        END as rate
        FROM groupevent as g 
        
           LEFT JOIN event e
              ON g.groupevent_id = e.groupevent_id
                 AND e.created_at between ${start_at} AND ${end_at}
        WHERE g.website_id=${website_id} 
        GROUP by g.groupevent_id
        ORDER BY  resultat DESC ;
        `,
      );
    It doesnt work on prisma.queryRaw because of monthClean, weekClean, yearClean being a float number, i checked on internet and they say it doesnt work on queryRaw, so i need to "the normal way" to see if it works like that too
  • a

    A. Sauder

    02/25/2022, 3:47 PM
    Hello together I have in a table a date field and one which gives the duration in minutes. now I want to read via findmany all entries where the date in the date field + the duration in minutes is greater than the current date. Can anyone of you help me?
    n
    • 2
    • 2
  • d

    Dev__

    02/25/2022, 3:47 PM
    I am trying to
    upsert
    a record in the database where the
    orderId
    must not have a value.
    Copy code
    .upsert({
    	create: {
    	    ...
    	},
    	update: {
    		...
    	},
    	where: {
    		id,
    		orderId: undefined
    	}
    })
    orderId
    is possible
    undefined
    because its an optional relation. how can I say in the
    where
    that is must match an
    id
    and where `orderId`'s value is empty. afaik
    undefined
    means do nothing, but I need it to do something
    z
    c
    • 3
    • 18
  • c

    Celestine

    02/25/2022, 7:06 PM
    I am trying to call a stored procedure using prisma. It is returning data, but the object in the result list doesn’t have the appropriate column names as key. My code looks something like this:
    Copy code
    const result = await this.prisma.$queryRaw<
          Prisma.categorySelect[]
        >`CALL catalog_get_categories_for_product(${productId})`;
    
        return result;
    The returned result looks like this:
    Copy code
    [
      {
        "f0": 1,
        "f1": 1,
        "f2": "French"
      }
    ]
    What I am expecting:
    Copy code
    [
      {
        "category_id": 1,
        "department_id": 1,
        "name": "French"
      }
    ]
    Does anyone have an idea why the column names are not being returned correctly?
    👀 1
    j
    • 2
    • 2
  • j

    Jonathan Marbutt

    02/25/2022, 8:32 PM
    When using relational queries like the ones in this example
    Copy code
    const users = await prisma.user.findMany({
      where: {
        posts: {
          none: {
            views: {
              gt: 100,
            },
          },
          every: {
            likes: {
              lte: 50,
            },
          },
        },
      },
    })
    It generated a pretty bad sql statement that looked something like this (not exact because I using a combination of examples)
    Copy code
    SELECT "public"."contact"."id", "public"."contact"."uuid", "public"."contact"."contact_id"  "public"."contact"."login_id" FROM "public"."contact" WHERE "public"."contact"."contact_id" IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$90,$91,$92,$93,$94,$95,$96,$97,$98,$99,$100,$101,$102,$103,$104,$105,$106,$107,$108,$109,$110,$111,$112,$113,$114,$115,$116,$117,$118,$119,$120,$121,$122,$123,$124,$125,$126,$127,$128,$129,$130,$131,$132,$133,$134,$135,$136,$137,$138,$139,$140,$141,$142,$143,$144,$145,$146,$147,$148,$149,$150,$151,$152,$153,$154,$155,$156,$157,$158,$159,$160,$161,$162,$163,$164,$165) OFFSET $166
    This seems like it would not work for larger applications using Postgres since we have many queries that may have 10k or 50k items that are in the
    IN
    array. Is it recommended to just go straight sql for those type of queries?
    i
    • 2
    • 7
  • m

    Marcin Cebula

    02/26/2022, 1:30 AM
    Is there a paid version of prisma where I can use a Proxy Server in Asia? Thanks
    n
    • 2
    • 1
  • p

    PinkiePie

    02/26/2022, 3:49 PM
    does Prisma works with monorepos? I have such an error
    Error during invocation:  Error: ENOENT: no such file or directory, open '/schema.prisma'
    and can see many issues on the GitHub about similar problems.
    s
    e
    • 3
    • 4
  • k

    Kelly Copley

    02/26/2022, 8:50 PM
    Previous issue fixed by updating prisma client.. Now does anyone know how to remove all relations at one time?
    • 1
    • 1
  • t

    Trenton K

    02/27/2022, 12:07 AM
    could someone point me in the right direction? I accidentally cleared all migrations from my production postgresql db and am trying to restore it from a .sql backup file
  • t

    Trenton K

    02/27/2022, 12:08 AM
    is there a primsa util for importing a .sql file into an existing but empty db?
  • i

    Ian Ray

    02/27/2022, 2:14 AM
    Open question about the state of multi-tenant prisma migrations today: https://github.com/prisma/prisma/issues/2443#issuecomment-1052946504
  • k

    Kelly Copley

    02/27/2022, 3:05 PM
    Does anyone know if it's possible to specify which relations to count in an
    _count
    ? Something like
    _count: { posts: { where: { published: true }}}
    t
    n
    • 3
    • 2
1...549550551...637Latest