keii
keii
Explore posts from servers
TTCTheo's Typesafe Cult
Created by keii on 6/21/2024 in #questions
Recommended way to prettyprint tRPC errors
Do you all have any preffered way/function to pretty print tRPC errors like zod?
4 replies
PPrisma
Created by keii on 5/1/2024 in #help-and-questions
Reason why relation is giving an error when id is provided
Hello im trying to create a new row but even when the id is provided it gives an error
2024-05-01 23:58:55 Invalid `prisma.entryAlternativeTitle.create()` invocation:
2024-05-01 23:58:55
2024-05-01 23:58:55 {
2024-05-01 23:58:55 data: {
2024-05-01 23:58:55 entryId: 11,
2024-05-01 23:58:55 languageId: 326,
2024-05-01 23:58:55 title: "Ο Χάρι Πότερ και η Φιλοσοφική Λίθος",
2024-05-01 23:58:55 + entry: {
2024-05-01 23:58:55 + create: EntryCreateWithoutAlternativeTitlesInput | EntryUncheckedCreateWithoutAlternativeTitlesInput,
2024-05-01 23:58:55 + connectOrCreate: EntryCreateOrConnectWithoutAlternativeTitlesInput,
2024-05-01 23:58:55 + connect: EntryWhereUniqueInput
2024-05-01 23:58:55 + }
2024-05-01 23:58:55 }
2024-05-01 23:58:55 }
2024-05-01 23:58:55
2024-05-01 23:58:55 Argument `entry` is missing.
2024-05-01 23:58:55 Invalid `prisma.entryAlternativeTitle.create()` invocation:
2024-05-01 23:58:55
2024-05-01 23:58:55 {
2024-05-01 23:58:55 data: {
2024-05-01 23:58:55 entryId: 11,
2024-05-01 23:58:55 languageId: 326,
2024-05-01 23:58:55 title: "Ο Χάρι Πότερ και η Φιλοσοφική Λίθος",
2024-05-01 23:58:55 + entry: {
2024-05-01 23:58:55 + create: EntryCreateWithoutAlternativeTitlesInput | EntryUncheckedCreateWithoutAlternativeTitlesInput,
2024-05-01 23:58:55 + connectOrCreate: EntryCreateOrConnectWithoutAlternativeTitlesInput,
2024-05-01 23:58:55 + connect: EntryWhereUniqueInput
2024-05-01 23:58:55 + }
2024-05-01 23:58:55 }
2024-05-01 23:58:55 }
2024-05-01 23:58:55
2024-05-01 23:58:55 Argument `entry` is missing.
schema:
model EntryAlternativeTitle {
id Int @id @default(autoincrement()) @db.UnsignedInt
entryId Int @db.UnsignedInt
entry Entry @relation(fields: [entryId], references: [id], onDelete: Cascade)
countryId Int? @db.UnsignedInt
country Country? @relation(fields: [countryId], references: [id], onDelete: Cascade)
languageId Int? @db.UnsignedInt
language Language? @relation(fields: [languageId], references: [id], onDelete: Cascade)
title String

createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model EntryAlternativeTitle {
id Int @id @default(autoincrement()) @db.UnsignedInt
entryId Int @db.UnsignedInt
entry Entry @relation(fields: [entryId], references: [id], onDelete: Cascade)
countryId Int? @db.UnsignedInt
country Country? @relation(fields: [countryId], references: [id], onDelete: Cascade)
languageId Int? @db.UnsignedInt
language Language? @relation(fields: [languageId], references: [id], onDelete: Cascade)
title String

createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
4 replies
PPrisma
Created by keii on 4/8/2024 in #help-and-questions
Wierd type error with prisma codegen
29.01 qrtag:build: ./prisma/client/runtime/edge-esm.js:1:1
29.01 qrtag:build: Type error: Declaration emit for this file requires using private name 'i'. An explicit type annotation may unblock declaration emit.
29.01 qrtag:build: ./prisma/client/runtime/edge-esm.js:1:1
29.01 qrtag:build: Type error: Declaration emit for this file requires using private name 'i'. An explicit type annotation may unblock declaration emit.
https://cdn.discordapp.com/attachments/1225878190891864104/1226937916312518707/image.png?ex=662695fa&is=661420fa&hm=6e04892eb54415c469c92fbe5b131f9abfcb1fbbf0f93037fd438f17eb787b21&
4 replies
PPrisma
Created by keii on 4/6/2024 in #help-and-questions
Turbo setup with prisma and pnpm
I have a setup using turborepo and running a few apps and some shared packages together and it works well in dev but i can't figure out how to setup docker, pnpm and prisma together. I've written my dockerfile below and my tree structure is Prisma; /apps/qrtag/prisma/prisma.schema /apps/qrtag/(nextjs app) /apps/qrtag/Dockerfile /docker-compose.yml Dockkerfile
# Builder
FROM node:alpine AS builder
RUN apk add --no-cache libc6-compat
RUN apk update

WORKDIR /app
RUN yarn global add turbo
COPY . .
COPY /apps/qrtag/prisma ./
RUN turbo prune --scope=qrtag --docker

# Installer
FROM node:alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update

WORKDIR /app
RUN yarn global add pnpm
RUN yarn global add turbo

COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm fetch
RUN pnpm install --offline
RUN pnpx prisma generate

COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json

# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM

# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN

RUN turbo build --filter=qrtag...

# Runner
FROM node:alpine AS runner
WORKDIR /app

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer /app/apps/qrtag/next.config.js .
COPY --from=installer /app/apps/qrtag/package.json .

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/qrtag/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/qrtag/.next/static ./apps/qrtag/.next/static
# COPY --from=installer --chown=nextjs:nodejs /app/apps/appname/public ./apps/appname/public

CMD node apps/qrtag/server.js
# Builder
FROM node:alpine AS builder
RUN apk add --no-cache libc6-compat
RUN apk update

WORKDIR /app
RUN yarn global add turbo
COPY . .
COPY /apps/qrtag/prisma ./
RUN turbo prune --scope=qrtag --docker

# Installer
FROM node:alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update

WORKDIR /app
RUN yarn global add pnpm
RUN yarn global add turbo

COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm fetch
RUN pnpm install --offline
RUN pnpx prisma generate

COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json

# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM

# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN

RUN turbo build --filter=qrtag...

# Runner
FROM node:alpine AS runner
WORKDIR /app

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer /app/apps/qrtag/next.config.js .
COPY --from=installer /app/apps/qrtag/package.json .

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/qrtag/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/qrtag/.next/static ./apps/qrtag/.next/static
# COPY --from=installer --chown=nextjs:nodejs /app/apps/appname/public ./apps/appname/public

CMD node apps/qrtag/server.js
docker-compose.yml
version: '3.8'
services:
mysql:
image: mysql:5.7
restart: always
ports:
- 3306:3306
expose:
- 3306
environment:
MYSQL_ROOT_PASSWORD: prisma
MYSQL_PASSWORD: prisma
MYSQL_USER: prisma
MYSQL_DATABASE: qrtag
volumes:
- mysql:/var/lib/mysql
app:
container_name: qrtag
build:
context: .
dockerfile: ./apps/qrtag/Dockerfile
ports:
- '3001:3001'
volumes:
mysql: ~
version: '3.8'
services:
mysql:
image: mysql:5.7
restart: always
ports:
- 3306:3306
expose:
- 3306
environment:
MYSQL_ROOT_PASSWORD: prisma
MYSQL_PASSWORD: prisma
MYSQL_USER: prisma
MYSQL_DATABASE: qrtag
volumes:
- mysql:/var/lib/mysql
app:
container_name: qrtag
build:
context: .
dockerfile: ./apps/qrtag/Dockerfile
ports:
- '3001:3001'
volumes:
mysql: ~
.dockerignore
**/node_modules
node_modules
**/node_modules
node_modules
2 replies
PPrisma
Created by keii on 3/30/2024 in #help-and-questions
Cannot select both '$scalars: true' and a specific scalar field 'tags'.
This is my relevant schema
model EventTag {
id Int @id @default(autoincrement()) @db.UnsignedInt
eventUserId Int @db.UnsignedInt
targetId Int @db.UnsignedInt
timestamp DateTime @default(now()) @db.DateTime(0)
target User @relation("event_tags_target_idTousers", fields: [targetId], references: [id], onUpdate: Restrict, map: "event_tags_target_id_foreign")
eventUser EventUser @relation(fields: [eventUserId], references: [id])

@@index([targetId], map: "event_tags_target_id_foreign")
}

model EventUser {
id Int @id @default(autoincrement()) @db.UnsignedInt
userId Int @db.UnsignedInt
eventId Int @db.UnsignedInt
isAlive Boolean @default(true)
secret String @db.VarChar(255)
targetId Int @db.UnsignedInt
event Event @relation(fields: [eventId], references: [id], onUpdate: Restrict, map: "event_users_event_id_foreign")
target User @relation("event_users_target_idTousers", fields: [targetId], references: [id], onUpdate: Restrict, map: "event_users_target_id_foreign")
user User @relation("event_users_user_idTousers", fields: [userId], references: [id], onUpdate: Restrict, map: "event_users_user_id_foreign")
tags EventTag[]

@@index([eventId], map: "event_users_event_id_foreign")
@@index([targetId], map: "event_users_target_id_foreign")
@@index([userId], map: "event_users_user_id_foreign")
}
model EventTag {
id Int @id @default(autoincrement()) @db.UnsignedInt
eventUserId Int @db.UnsignedInt
targetId Int @db.UnsignedInt
timestamp DateTime @default(now()) @db.DateTime(0)
target User @relation("event_tags_target_idTousers", fields: [targetId], references: [id], onUpdate: Restrict, map: "event_tags_target_id_foreign")
eventUser EventUser @relation(fields: [eventUserId], references: [id])

@@index([targetId], map: "event_tags_target_id_foreign")
}

model EventUser {
id Int @id @default(autoincrement()) @db.UnsignedInt
userId Int @db.UnsignedInt
eventId Int @db.UnsignedInt
isAlive Boolean @default(true)
secret String @db.VarChar(255)
targetId Int @db.UnsignedInt
event Event @relation(fields: [eventId], references: [id], onUpdate: Restrict, map: "event_users_event_id_foreign")
target User @relation("event_users_target_idTousers", fields: [targetId], references: [id], onUpdate: Restrict, map: "event_users_target_id_foreign")
user User @relation("event_users_user_idTousers", fields: [userId], references: [id], onUpdate: Restrict, map: "event_users_user_id_foreign")
tags EventTag[]

@@index([eventId], map: "event_users_event_id_foreign")
@@index([targetId], map: "event_users_target_id_foreign")
@@index([userId], map: "event_users_user_id_foreign")
}
and this is my query
return await prisma.eventUser.findMany({
where: {
eventId: event.id,
},
include: {
user: true,
tags: true,
},
});
return await prisma.eventUser.findMany({
where: {
eventId: event.id,
},
include: {
user: true,
tags: true,
},
});
how would i fix this error?
Cannot select both '$scalars: true' and a specific scalar field 'tags'.
Cannot select both '$scalars: true' and a specific scalar field 'tags'.
I've checked relevant github issues and seems like this error is common and vague
4 replies
DTDrizzle Team
Created by keii on 3/25/2024 in #help
Add function to table in schema.ts
I come from a background using the Eloquent ORM in Laravel where you can add methods to the models so you can do something like user.isAdmin() (example with js syntax). Is it possible in Drizzle to add a function to the table so after I've queried a row I can do something similar like
const user = (await db.select()
.from(users)
.where(
eq(users.username, request.nextUrl.searchParams.get("viewer")!),
))[0];

if(user.isAdmin())
{
console.log("is Admin")
}
const user = (await db.select()
.from(users)
.where(
eq(users.username, request.nextUrl.searchParams.get("viewer")!),
))[0];

if(user.isAdmin())
{
console.log("is Admin")
}
or would i have to define helpers like
const isUserAdmin(user: User) {
return true;
}
const isUserAdmin(user: User) {
return true;
}
worth to note that in this example I would have a user_admins table with a one-to-one reference to a User not a is_admin column on the users table
1 replies
VVALORANT
Created by keii on 2/17/2024 in #community-help
Can't go into account settings on playvalorant.com
No description
48 replies
CC#
Created by keii on 8/8/2023 in #help
Do static classes leak memory?
I have made a simple 2d game engine currently built on SDL2 to work on the api and such. What i've noticed is that the game engine is leaking loads of memory (around 2 mb a second) and i'm trying to figure out why. Now the entire game engine is composed of static classes so that you can do calls like Draw.Rectangle(x, y, w, h) and likewise to ease the learning curve and Draw.Rectangle adds a class to a list which is drawn and cleared every frame. Do static classes not clear memory or something similar or do i have another problem? I have checked the rider memory debugger and it says that the Rectangle class takes up around 255 kb which should not be happening.
28 replies