packofm&ms
packofm&ms
TTCTheo's Typesafe Cult
Created by packofm&ms on 8/7/2024 in #questions
MonkeyType
No description
12 replies
TTCTheo's Typesafe Cult
Created by packofm&ms on 4/15/2023 in #questions
Want all records to be deleted given a specified datetime
Basically, I want to be able to delete a record, which contains a datetime value called lets say deleteAt, at the time deleteAt specifies. For example, if a user creates a post, and assigns 4/15/23 12:00 AM as the deleteAt value, how can I delete it at that time, given that I'm using the t3 stack?
12 replies
TTCTheo's Typesafe Cult
Created by packofm&ms on 4/9/2023 in #questions
Trying to implement infinite scroll with infinite query
So i was looking at this video to see how this guy implememented infintie scroll: https://www.youtube.com/watch?v=nzJsYJPCc80&t=3592s (his github repo in description, and the part of the video is labeled), and the way he made it is kind of glitchy, when I scroll down, it just fetches the same data over and over which happens in his video as well, and when I print the nextcursor, which is the id of the next record, its always the same for some reason. I pretty much have the same code as him except I just have my own schema that i use instead of tweet, which shouldn't make a difference at all.
3 replies
TTCTheo's Typesafe Cult
Created by packofm&ms on 4/2/2023 in #questions
make geocoding request serverside or clientside?
So my user will enter an address and I want to convert that address to latitude and longitude numbers using a geocoding api to store in my db. However, do I make that request on client side and pass it into the mutation procedure as its own input, or should I do it serverside within the procedure itself? What are the pros and cons?
7 replies
TTCTheo's Typesafe Cult
Created by packofm&ms on 12/22/2022 in #questions
Need help with setting up prisma schemas
so basically I want a user to be able to create and join events. I've set up a way to identify the host of an event, but not how to keep track of the members of the event (those who join the event). I kept getting some errors when I tried to implement it myself and it was hard to keep track of them so i got rid of what i had cause it was not working. What is a good way of keeping track of Users who join the event?
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
hostedEvents Event[] @relation(name: "hostEvent")
}

model Event {
id String @id @default(cuid())
name String
description String
startDate DateTime
endDate DateTime
location String
link String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
hostId String
host User @relation("hostEvent", fields: [hostId], references: [id])
Gallery Gallery[]
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
hostedEvents Event[] @relation(name: "hostEvent")
}

model Event {
id String @id @default(cuid())
name String
description String
startDate DateTime
endDate DateTime
location String
link String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
hostId String
host User @relation("hostEvent", fields: [hostId], references: [id])
Gallery Gallery[]
}
7 replies
TTCTheo's Typesafe Cult
Created by packofm&ms on 11/29/2022 in #questions
Mutations run in an weird order
So basically I want to create a room using a question and name a user inputs, which would be the input and name state variables. The room is created every time, which is what I want since I need the room id to add the user. The issue is that when the user submits the create a room form, the member is not created nor are they added to the room initially. However, when the user resubmits the form with the same data, a new room is created and the new member is created in the database. I want the member and room to be created on the first submit of the form, but can't seem to figure out why it isn't working. Any help would be appreciated. Here is the snippet of code:
e.preventDefault();
// create a room
room.mutateAsync({
question: input
});



if (room && room.data){

member.mutate({
name,
roomId: room.data.id,
isHost: true,


});
e.preventDefault();
// create a room
room.mutateAsync({
question: input
});



if (room && room.data){

member.mutate({
name,
roomId: room.data.id,
isHost: true,


});
And here is my schema I'm using:
model Room {
id String @id @default(cuid())
question String
answers Answer[]
members Member[]
}

model Member {
id String @id @default(cuid())
isHost Boolean
name String
roomId String
room Room @relation(fields: [roomId], references: [id])
answers Answer[]
}
model Room {
id String @id @default(cuid())
question String
answers Answer[]
members Member[]
}

model Member {
id String @id @default(cuid())
isHost Boolean
name String
roomId String
room Room @relation(fields: [roomId], references: [id])
answers Answer[]
}
12 replies