Jordansz
11/15/2021, 12:25 PMArgument id: Got invalid value 'ckvxz34bl0000074mhkz1y27g' on prisma.findManyMembership. Provided String, expected IntFilter or Int:
errorRyan
11/15/2021, 12:51 PMJordansz
11/15/2021, 12:52 PMJordansz
11/15/2021, 12:52 PMJordansz
11/15/2021, 12:52 PM// 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])
}
Jordansz
11/15/2021, 12:53 PMJordansz
11/15/2021, 12:53 PMimport { 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
Jordansz
11/15/2021, 12:54 PMRyan
11/15/2021, 12:58 PMprisma generate
and then checkJordansz
11/15/2021, 1:26 PMJordansz
11/15/2021, 1:34 PMJordansz
11/15/2021, 1:34 PMJordansz
11/15/2021, 1:34 PMJordansz
11/15/2021, 1:35 PMRyan
11/15/2021, 1:40 PMmembership.findMany
callRyan
11/15/2021, 1:40 PMJordansz
11/15/2021, 1:54 PMJordansz
11/15/2021, 1:55 PMJordansz
11/15/2021, 1:56 PMJordansz
11/15/2021, 1:56 PMJordansz
11/15/2021, 1:57 PMRyan
11/15/2021, 2:00 PMckw0ny0oa0000544mbdxi5yrt
that you’re passing should be an Int and not a String. You need to pass a numeric value.Jordansz
11/15/2021, 2:03 PMRyan
11/15/2021, 2:29 PMparseInt
. And it’s not possible that it was working before, your id
field in the Membership
model is an Int
.Jordansz
11/15/2021, 2:36 PM