hello everyone im all out of sudden get a ```Argum...
# orm-help
j
hello everyone im all out of sudden get a
Copy code
Argument id: Got invalid value 'ckvxz34bl0000074mhkz1y27g' on prisma.findManyMembership. Provided String, expected IntFilter or Int:
error
r
@Jordansz You are passing a String where it’s expecting an Int. Could you share the query and schema related to this?
j
yes which is strange since I havent modified the scheme let me paste it
schema is like:
Copy code
// This is your Prisma schema file,
// learn more about it in the docs: <https://pris.ly/d/prisma-schema>

datasource db {
  provider = "postgres"
  url      = env("DATABASE_URL")
}

//generator erd {
//  provider = "prisma-erd-generator"
//  output   = "./diagram.pdf"
//}

generator client {
  provider = "prisma-client-js"
}

// --------------------------------------

model User {
  id             Int          @id @default(autoincrement())
  createdAt      DateTime     @default(now())
  updatedAt      DateTime     @updatedAt
  email          String       @unique
  hashedPassword String?
  role           String       @default("USER")
  avatar         Json?
  tokens         Token[]
  sessions       Session[]
  memberships    Membership[]
}

model Session {
  id                 Int       @id @default(autoincrement())
  createdAt          DateTime  @default(now())
  updatedAt          DateTime  @updatedAt
  expiresAt          DateTime?
  handle             String    @unique
  hashedSessionToken String?
  antiCSRFToken      String?
  publicData         String?
  privateData        String?

  user   User? @relation(fields: [userId], references: [id])
  userId Int?
}

model Token {
  id          Int       @id @default(autoincrement())
  createdAt   DateTime  @default(now())
  updatedAt   DateTime  @updatedAt
  hashedToken String
  lastFour    String?
  // type        String
  // See note below about TokenType enum
  type        TokenType
  expiresAt   DateTime
  sentTo      String?

  user   User? @relation(fields: [userId], references: [id])
  userId Int?

  workspace   Workspace? @relation(fields: [workspaceId], references: [id])
  workspaceId String?

  @@unique([hashedToken, type])
}

// NOTE: It's highly recommended to use an enum for the token type
//       but enums only work in Postgres.
//       See: <https://blitzjs.com/docs/database-overview#switch-to-postgresql>

enum TokenType {
  RESET_PASSWORD
  INVITE_TOKEN
  PUBLIC_KEY
  SECRET_KEY
}

model Workspace {
  id         String   @id @default(cuid())
  createdAt  DateTime @default(now())
  modifiedAt DateTime @default(now())

  name String
  slug String @unique

  memberships Membership[]

  stripeCustomerId       String?   @unique
  stripeSubscriptionId   String?   @unique
  stripePriceId          String?
  stripeCurrentPeriodEnd DateTime?

  tokens Token[]
}

enum MembershipRole {
  OWNER
  ADMIN
  USER
}



model Membership {
  id   Int            @id @default(autoincrement())
  role MembershipRole

  workspace   Workspace @relation(fields: [workspaceId], references: [id])
  workspaceId String

  user   User @relation(fields: [userId], references: [id])
  userId Int
  @@unique([userId, workspaceId])
}
my query is :
Copy code
import { paginate, Ctx } from "blitz"
import db, { Prisma } from "db"

interface GetMembershipsInput
  extends Pick<Prisma.MembershipFindManyArgs, "where" | "orderBy" | "skip" | "take"> {}

async function getMemberships(
  { where, orderBy, skip = 0, take = 100 }: GetMembershipsInput,
  ctx: Ctx
) {
  ctx.session.$authorize("ADMIN")

  const { items: memberships, hasMore, count } = await paginate({
    skip,
    take,
    count: () => db.membership.count({ where }),
    query: (paginateArgs) =>
      db.membership.findMany({
        ...paginateArgs,
        where,
        orderBy,
      }),
  })

  return {
    memberships,
    hasMore,
    count,
  }
}

export default getMemberships
i also reverted my code back to the original rendering of the html that calls this link, its just the /workspaces/id slug here nothing changed on that. So tried using '1' instead ( without the quotes)
r
Try running
prisma generate
and then check
j
ok let met try
that did not resolve the issue sadly
very newbie to prisma could you givem e some pointers on how to debug these kinds of issues
prisma thinks its an string not an integer. not sure why it worked before then.
i just pass it in the url. prisma is awesome btw further building a large project on it
r
I want to see the data you're passing in the above
membership.findMany
call
The data you're passing is the issue here
j
ok let met try how to retrieve that
not exactly sure how i would output them
the url i call this with is /admin/workspaces/ckw0ny0oa0000544mbdxi5yrt
which worked fine before
im not sure on the prisma types but Argument id: Got invalid value 'ckw0ny0oa0000544mbdxi5yrt' on prisma.findManyMembership. Provided String, normally on integer you would think it would be only nummerical
r
This value:
ckw0ny0oa0000544mbdxi5yrt
that you’re passing should be an Int and not a String. You need to pass a numeric value.
j
yes i understand but this before have not any issues. If i pass an 1 or 2 it throws the same error though
r
You need to use
parseInt
. And it’s not possible that it was working before, your
id
field in the
Membership
model is an
Int
.
j
ok i look at it later thank you very much Ryan for your time