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

    Darkyne

    01/26/2022, 10:01 PM
    Hey guys, I'm currently going insane
    const name = _input_.name ?? undefined;
       
    const categories = _input_.categories ?? undefined;
       
    const games = await prisma.game.findMany({
         
    where: {
           
    AND: {
             
    name: { contains: name, mode: 'insensitive' },
             
    categories: {
               
    some: {
               
    }
             
    }
           
    }
         
    },
    I have this query and I'm trying to to check if any category matches one of the categories array (input) how do I map this?
    s
    • 2
    • 33
  • n

    Nathaniel Bajo

    01/27/2022, 11:21 AM
    Hey guys, so I created a server with prisma as it's database and it has been so confusing and difficult because raspberrypi4 does not support prisma-engines and the program running on my server requires it so right now I'm trying to test the server on my system and it's showing this.
    • 1
    • 1
  • n

    Nathaniel Bajo

    01/27/2022, 11:21 AM
  • m

    Martijn Burger

    01/27/2022, 12:54 PM
    Hey everyone. I am using postgres json and I was wondering if I can select specific fields from a json field using prisma. So, for instance this query
    *select* p."json"->>'email' *as* email *from* "Party" p
    in prisma. Something like:
    db.party.findMany({ select: { json->>'email': true } })
    ?
    n
    • 2
    • 3
  • f

    Friedrich Mäckle

    01/27/2022, 1:30 PM
    Hello, I tried to use Prisma Data Proxy from AWS-Lambda but I am getting a https://www.prisma.io/docs/concepts/components/prisma-data-platform#p5002 error, url looks fine to me (prisma://aws-eu-central-1.prisma-data.com/?api_key=ABC), so I wonder what is the cause for this
    n
    j
    • 3
    • 11
  • f

    Friedrich Mäckle

    01/27/2022, 1:30 PM
    The slack channel mentioned in the docs do not seem to exist: https://www.prisma.io/docs/concepts/components/prisma-data-platform#feedback-and-support
    n
    • 2
    • 1
  • k

    Kay Khan

    01/27/2022, 2:18 PM
    If i want to do a manual join without the use of include (because there is no FK setup, the id i want to join on is generic and can related to multiple tables) is it possible?
  • r

    Reuben Porter

    01/27/2022, 3:53 PM
    Hi, I’m using Prisma and trying to do a 
    concat
     query. Basically we have a user’s table with 
    FirstName
     and 
    lastName
    , and we’re using a `contains`/`LIKE` search. I.e if I search “Nathan” it will search firstName and lastName columns for “Nathan”, and if it finds it, return the row(s), great! Likewise if I search “Sainsbury”, it will return the row. However, should I search “Nathan Sainsbury” I would find no results as “Nathan Sainsbury” is not contained with “Nathan” or “Sainsbury”. In SQL I’d be able to do something like:
    Copy code
    select * from "User"
    where concat("firstName", ' ', "lastName") LIKE '%Nathan Sainsbury%';
    Is there anyway to do this in Prisma without a raw query?
  • a

    Austin Zentz

    01/27/2022, 4:03 PM
    i think raw query is the way to go
  • a

    Austin Zentz

    01/27/2022, 4:04 PM
    another option, if you have the flexibility in terms of how data gets into your database, would be to have some kind of search column that you set to `${firstName} ${lastName} when you're saving or updating data. And then you can do a full text search on that column, which Prisma supports with the fullTextSearch preview in Postgres/MySQL.
    👀 1
  • r

    Reuben Porter

    01/27/2022, 4:05 PM
    Yeah I did consider that option tbf
  • a

    Austin Zentz

    01/27/2022, 4:05 PM
    But that may not work if you have an existing database or if you're not able to reliably do the before-save action
  • a

    Austin Zentz

    01/27/2022, 4:05 PM
    the nice thing about the "search" column is that's it's indexable
  • a

    Austin Zentz

    01/27/2022, 4:06 PM
    so you can use that for awhile before having to go to something like elasticSearch, whereas the concat option will degrade faster as your DB size increases
  • r

    Reuben Porter

    01/27/2022, 4:06 PM
    not keen on the idea of having to add a whole new col just for that though
  • a

    Austin Zentz

    01/27/2022, 4:06 PM
    yeah, i know what you mean
  • r

    Reuben Porter

    01/27/2022, 4:07 PM
    thanks for your response anyway
  • a

    Austin Zentz

    01/27/2022, 4:09 PM
    np
  • d

    Darkyne

    01/27/2022, 8:25 PM
    Is there a more elegant way to filter a relational field in prisma instead of this:
    Copy code
    where: {
      AND: [
        ...categories!.map((value) => ({ categories: { some: { description: { contains: value } } } })),
      ]
    },
    and no, some or every will not suffice (at least not in its most basic form) hasEvery would be preferable but it seems to only be available to scalar fields or mongodb relations (I use postgresql)
    m
    • 2
    • 6
  • n

    Nathaniel Babalola

    01/27/2022, 8:50 PM
    Hi all, how do I setup a relationship where there's a
    User
    table and a
    Transactions
    table for storing transactions between users. The
    Transactions
    table has a from and to field , which should reference the id of the users sending and receiving on
    User
    table. How can 2 fields/columns reference the same key on another table. I can't do any of these.
    Copy code
    user  user  @relation(fields: [from, to], references :[id] )
    user  user  @relation(fields: [from, to], references :[id, id] )
    Please any help is greatly appreciated.
    n
    • 2
    • 2
  • d

    Dan Shapir

    01/27/2022, 11:23 PM
    How can you filter by part of the query in an include? Like
    Copy code
    SELECT * FROM A INNER JOIN B on B.aId = A.id AND B.amount < A.price
    or
    Copy code
    SELECT * FROM A INNER JOIN B on a.aId = A.id WHERE B.amount < A.price
    Meaning your query’s filter parameter is part of the query itself. I couldn’t figure anyway to do it and it’s crazy… This is a super basic SQL capability
  • u

    박기웅

    01/28/2022, 2:50 AM
    How can i solve this error? os: centos7 db: postgresql12
  • j

    johngonzalez

    01/28/2022, 3:15 AM
    Hi Friends, You know when will be available parte 3 of the fullstack course? I have enjoyed the two first parts. Excellent work @Mahmoud https://www.prisma.io/blog/fullstack-nextjs-graphql-prisma-oklidw1rhw
    prisma cool 1
    n
    • 2
    • 2
  • u

    user

    01/28/2022, 9:30 AM
    Fullstack App With TypeScript, PostgreSQL, Next.js, Prisma &amp; GraphQL: Authentication This article is the third part of the course where you build a fullstack app with Next.js, GraphQL, TypeScript, Prisma and PostgreSQL. In this article, you will learn how to add authentication to your app.
    ✅ 1
  • n

    Nothing.

    01/28/2022, 10:03 AM
    Hello there. Will prisma add support for Deno anytime soon?
    n
    t
    • 3
    • 3
  • m

    Michael Buller

    01/28/2022, 4:28 PM
    I am attempting to query sql server using a stored procedure in prisma 3.8.
    "Could not find stored procedure 'Case-Clinical.dbo.usp_ProviderSearch'.
    I run the query on the database, everything is fine. I run it using prisma and I get that error message. I logged into the database using same user as prisma uses.
    Copy code
    // let results = await this.data.$queryRaw<ProviderSearch[]>`exec [dbo].usp_ProviderSearch 
          // @Search = ${input.search} ,
          // @City = ${input.city} ,
          // @PostalCode = ${input.postalCode} ,
          // @Specialty = ${input.specialty} ,
          // @Rating = ${input.rating} ,
          // @Latitude = ${input.latitude} ,
          // @Longitude = ${input.longitude} ,
          // @DistanceMiles = ${input.distanceMiles} 
          // `
    
          let results = await this.data.$queryRawUnsafe<ProviderSearch[]>(`exec [Case-Clinical].[dbo].usp_ProviderSearch`)
  • m

    Michael Buller

    01/28/2022, 4:28 PM
    Anyone else having trouble with prisma recognizing the stored procedure?
  • a

    Amol Patel

    01/28/2022, 4:50 PM
    Hey all, we recently ran into an issue with migration ordering and was wondering if theres any way we can avoid this going forward. Problem described below: Problem: PR 1 had a migration named 20220110_foo_bar PR 2 had a migration named 20220115_foo_baz We accidentally merged in PR 2 first and ran the migration in prod. Prisma or git didn’t complain (but we wish it did). PR 1 was merged afterwards and ran in prod. The nature of the migration didn’t directly impact the migration in PR 2 so we were ok but now our migrations are out of sync/complaining when developing locally. We can manually fix the issue by removing the entry in
    _prisma_migrations
    and commenting out the SQL in PR 1 but this is a hack and we are lucky. Question: Can prisma migrations be numbered sequentially? Or, is there a migration state file we can generate and check in to our codebase? Very similar to how Django handles migrations. I feel like this is a pretty obvious drawback and am wondering if anyone else has faced this issue. Thanks in advance!
    💯 3
    f
    n
    • 3
    • 9
  • m

    Mitchell Amihod

    01/28/2022, 6:40 PM
    👋 Anyone know, is prisma still swallowing up the SIGTERM signal in nodejs? (on prisma client 3.7)
  • m

    Mitchell Amihod

    01/28/2022, 6:44 PM
    I thought there was some change in 3 that would let you not have that behaviour, but i could be wrong (its been a few months since i last looked into it)
1...538539540...637Latest