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

    shahrukh ahmed

    04/13/2022, 2:38 PM
    Hi, In one-to-many relation like this, suppose you want to create a post, how would the create operation look like? Would it be possible to include examples of crud operations in the documentation for relationships as well? https://www.prisma.io/docs/concepts/components/prisma-schema/relations/one-to-many-relations
    n
    • 2
    • 3
  • b

    Brothak

    04/13/2022, 2:45 PM
    What does error Error: The underlying table for model user does not exist mean? I am getting this one running migrate dev. It’s caused by a migration which alter a column of a table which is in database and was created previously.
    s
    n
    • 3
    • 11
  • m

    Matthew Hammond

    04/13/2022, 3:17 PM
    Copy code
    Hi Everyone, I have an error I need some help with.
    We have a table called users that has some columns that are foreign keys. organization_id is the first foreign key in this table.
    The issue is that when using update in prisma.users.update I can't update fields which are foreign keys in the users table in my sql database. I can't find
    information related to this in the documentation. The sql query below does the update but does not work when I use update with prisma.
    
    This query works: 
    const result = await prisma.$queryRaw`UPDATE users
    SET name=${bodyData.name}, email=${bodyData.email}, roles=${bodyData.roles} , organization_id=${parseInt(bodyData.organization_id)}
    WHERE users.id = ${parseInt(bodyData.id)}`;
    
    This doesn't work: 
    
    await prisma.users.update({
        where: {
          id: parseInt(bodyData.id),
        },
        data: {
          name: bodyData.name,
          email: bodyData.email,
          roles: bodyData.roles,
          organization_id: bodyData.organization_id,
        },
    });
    
    We get this error: 
    
    Unknown arg `organization_id` in data.organization_id for type usersUpdateInput. Did you mean `organizations`? Available args:
    type usersUpdateInput {
      id?: BigInt | BigIntFieldUpdateOperationsInput
      name?: String | NullableStringFieldUpdateOperationsInput | Null
      auth0_id?: String | NullableStringFieldUpdateOperationsInput | Null
      email?: String | NullableStringFieldUpdateOperationsInput | Null
      roles?: String | NullableStringFieldUpdateOperationsInput | Null
      inserted_at?: DateTime | DateTimeFieldUpdateOperationsInput
      updated_at?: DateTime | DateTimeFieldUpdateOperationsInput
      organizations?: organizationsUpdateOneWithoutUsersInput
    }
    Copy code
    If I wanted to update the value of these foreign keys in my update using prisma, how could I do this? Here is my prisma.users.update that is causing the error:
    Organization_id is the first foreign key in my table and trying to update this is what causes the error. I can update the fields before that are not foreign Organization_id with no issue.
    My prisma schema matches the database.
    n
    • 2
    • 2
  • s

    shahrukh ahmed

    04/13/2022, 4:36 PM
    Is there a non-jargon-y definition of what
    scalar
    means. For example take this sentence.
    Copy code
    The following example includes a scalar list and a list of related models:
    a
    • 2
    • 1
  • a

    alexwasik

    04/13/2022, 5:48 PM
    👋
  • a

    alexwasik

    04/13/2022, 5:49 PM
    Hopefully a simple question. I have a table
    Move
    which has
    matchId
    and
    playerId
    (among other things). I want to get all the moves for both players from the
    matchId
    but I'm struggling to write the prisma query. DB is SQLite
  • a

    alexwasik

    04/13/2022, 5:51 PM
    Copy code
    const playersId = ['foo', 'bar'];
    prisma.move.findMany({
          where: {
            matchId,
          },
    // Lost after this
    });
  • a

    alexwasik

    04/13/2022, 6:03 PM
    got it
    Copy code
    await prisma.move.findMany({
          where: {
            matchId,
            playerId: {
              in: players
            }
          },
        });
    🙌 1
    🚀 1
  • d

    Dog

    04/13/2022, 9:00 PM
    Hi guys, I'm running into an "issue" that I am not 100% sure of how to handle. I was able to tackle it, but I wanna see what you guys think. Basically, I have a bunch of tweets. From each tweet I get it's content and the user. The issue is that the user also gives back it's password! To tackle this, I ended up doing this:
    Copy code
    await prisma.tweet.findMany({
    			include: {
    				user: {
    					select: {
    						id: true,
    						displayName: true,
    						username: true,
    					},
    				},
    			},
    		});
    I basically decide to take all fields from the user, besides the password. Is this the best way to do it? Since I might be using other models that require me to get the user, doing this on every query seems a bit repetitive. I was thinking I could do 2 things: Have the private info of the user in 1 model and all the public one in another. So the User model would have an id, password and email and the Profile the username, displayName, etc. The second option would be to keep the models as they are and instead just save an object in another file that looks kinda like this
    Copy code
    {
     id: true,
     displayName: true,
    //etc
    }
    and then just put that in every select so that at least, if the user model changes, it updates in all queries that involve the user.
    i
    a
    • 3
    • 16
  • i

    Ian Ray

    04/13/2022, 9:02 PM
    Dog is typing?!
  • d

    Dog

    04/13/2022, 9:02 PM
    What would you guys say is best? I think the first option would be easier to use, but I'm not too sure if its a good idea to separate things like that.
    😹 1
  • d

    Dog

    04/13/2022, 9:07 PM
    Personally I think having an option to have certain fields hidden by default would be cool. For example, you can mark the password field in a user as @hiddenByDefault (or something like that, idk) and then you can manually decide to include it if wanted. That would be super nice. You only need to get the password like once (when logging in) and thats it. Instead of having to hide the password every time, just have it so it can be included when needed. No?
    n
    • 2
    • 1
  • k

    kyle travelet

    04/13/2022, 10:18 PM
    Hey all I'm having some issues with seeding inside of GitHub actions to an AWS rds postgres database. I can connect locally and another action can connect successfully through .NET. The error I'm getting is very generic Can't reach database server at `<database name>.cetrsfy7iaye.us-east-1.rds.amazonaws.com`:`5432` Please make sure your database server is running at `<database name>.cetrsfy7iaye.us-east-1.rds.amazonaws.com`:`5432`. Is there some connection flag I need to set? I've tried ?sslmode= require and disable but no luck.
    n
    • 2
    • 1
  • j

    Jeremy Cohen Hoffing

    04/13/2022, 11:13 PM
    Hello! I'm building an app using Remix + Prisma + PlanetScale + Vercel. What are the advantages of creating a cloud prisma project with Planetscale and using Prisma Data Proxy vs not? Planetscale already offers the benefits of scaling thousands of db connections in a serverless environment from what I understand, so I'm curious what the added benefit is of the Data Proxy.
    n
    • 2
    • 2
  • m

    Matt Young

    04/14/2022, 12:23 AM
    I am desperate for help
  • m

    Matt Young

    04/14/2022, 12:24 AM
    I am looking for a way that enums field names can be manipulated
    v
    n
    • 3
    • 4
  • b

    Brothak

    04/14/2022, 5:01 AM
    What does error Error: The underlying table for model user does not exist mean? I am getting this one running migrate dev. It’s caused by a migration which alter a column of a table which is in database and was created previously.
    n
    • 2
    • 1
  • h

    Hwanseok Yu

    04/14/2022, 6:45 AM
    Somebody heeeeeeeeelp😭
    n
    • 2
    • 1
  • b

    Brothak

    04/14/2022, 7:02 AM
    In what order does prisma run migrations? Seems that in my cases it’s in reverse. I have two migrations and they fail because second which updates table is run before the one which creates the table.
    n
    • 2
    • 1
  • p

    phil2srass

    04/14/2022, 7:46 AM
    How are we doing an inner join with Prisma ? const list: any = await prisma.operateur_forfait.findMany({ include: { operateur_france_tarif: { select: { id: true, }, where: { vers: parseInt(lieuId), }, }, operateur: true, }, });
    n
    • 2
    • 1
  • p

    phil2srass

    04/14/2022, 7:46 AM
    That makes a left join..
  • p

    phil2srass

    04/14/2022, 7:47 AM
    I have the lines with no data in operateur_france_tarif
  • s

    shahrukh ahmed

    04/14/2022, 8:21 AM
    Is there a way I can use a single dB with Prisma in two different projects?
    n
    • 2
    • 2
  • d

    Danny SMc

    04/14/2022, 10:55 AM
    Hello everyone. Question for you, do we have the following features (I assume not due to lack of documentation, but I thought I would ask): 1. The ability to import/use multiple schema files. For example, I have a framework that integrates Prisma and it's perfect and works well, but my framework is expandable, and I would like to work on let's say a Blog plugin for my framework. I would of course want to define the schema required for the blog and when it gets setup in my database, that the prisma CLI could look for the additional schema and when the user runs
    yarn prisma generate
    that would take into account the other
    *.schema
    file(s) as well. 2. The ability to use multiple databases, I did find a github issue here, what is the actual status of this? As I see it was made almost 2 years ago: https://github.com/prisma/prisma/issues/1122
    n
    • 2
    • 5
  • p

    Perez cato Cato perez

    04/14/2022, 11:13 AM
    Hello everyone does prisma support cockroach db for production
    👋 2
    n
    • 2
    • 2
  • s

    shahrukh ahmed

    04/14/2022, 1:48 PM
    Hi, Had a question about foreign key. Suppose I wanted a post with id : 1 and user : 1 (user being parent), how would I go about it?
    Copy code
    const event = await prisma.posts.findUnique({
        where: {
          id: 1
        }
      });
    a
    • 2
    • 4
  • a

    Adam Boulila

    04/14/2022, 2:30 PM
    is it possible (recommended) to access prisma interfaces from frontend to add typing to responses from fetch requests
    a
    • 2
    • 2
  • g

    GN Vageesh

    04/14/2022, 5:07 PM
    hi guys
  • g

    GN Vageesh

    04/14/2022, 5:07 PM
    i had a question
  • g

    GN Vageesh

    04/14/2022, 5:08 PM
    is there a way to get an item by id, and if it doesn't exist... then create the item
    a
    • 2
    • 2
1...563564565...637Latest