noctate
noctate
Explore posts from servers
TTCTheo's Typesafe Cult
Created by kenny on 4/19/2023 in #questions
How to SSG a page from my T3 app??
May I Ask what data do you need statically generated? Seems odd for a chat
78 replies
TTCTheo's Typesafe Cult
Created by noctate on 4/17/2023 in #questions
kysely join select query
I see! Thank you!
9 replies
TTCTheo's Typesafe Cult
Created by noctate on 4/17/2023 in #questions
kysely join select query
Its interesting because if I would do query that don't use count then both votedAgainstId and voteForId are in the result
9 replies
TTCTheo's Typesafe Cult
Created by noctate on 4/17/2023 in #questions
kysely join select query
Nope, the voteAgainst Has the same count value as voteFor. But when I change the leftJoin to use 'votedAgainstId', the opposite is happening.
9 replies
TTCTheo's Typesafe Cult
Created by noctate on 4/2/2023 in #questions
insert query in kysely, typerror
after some research I changed the type to this interface
VoteAnime {
id: Generated<string>;
votedForId: number;
votedAgainstId: number;
createdAt: Generated<Date>;
}
VoteAnime {
id: Generated<string>;
votedForId: number;
votedAgainstId: number;
createdAt: Generated<Date>;
}
but now I get error: Field 'id' doesn't have a default value when trying to fire mutation. when constructing the prisma schema and pushing it to database I chosed
id String @id @default(cuid())
id String @id @default(cuid())
so I guess it should have a default value?
4 replies
TTCTheo's Typesafe Cult
Created by noctate on 4/2/2023 in #questions
insert query in kysely, typerror
to give more context the this is vote anime type:
type VoteAnime = {
id: string
createdAt: Date
votedForId: number
votedAgainstId: number
animeId: number | null
}
type VoteAnime = {
id: string
createdAt: Date
votedForId: number
votedAgainstId: number
animeId: number | null
}
4 replies
TTCTheo's Typesafe Cult
Created by Simvolick on 3/7/2023 in #questions
Any resources to learn the tRPC better? Hopefully with guides and examples?
But its recommended i think
18 replies
TTCTheo's Typesafe Cult
Created by Simvolick on 3/7/2023 in #questions
Any resources to learn the tRPC better? Hopefully with guides and examples?
I also use zod to parse the data to know its shape but you don't have to do that
18 replies
TTCTheo's Typesafe Cult
Created by Simvolick on 3/7/2023 in #questions
Any resources to learn the tRPC better? Hopefully with guides and examples?
In one of my project I do it like this:
export const coinRouter = router({
getCoin: publicProcedure
.input(z.object({ name: z.string()}))
.query(async ({ input }) => {
const coin = await fetch(`https://api.coingecko.com/api/v3/coins/${input.name}?sparkline=true`).then(res =>
res.json());
const parsedData = coinResult.parse(coin)
return parsedData
})
})
export const coinRouter = router({
getCoin: publicProcedure
.input(z.object({ name: z.string()}))
.query(async ({ input }) => {
const coin = await fetch(`https://api.coingecko.com/api/v3/coins/${input.name}?sparkline=true`).then(res =>
res.json());
const parsedData = coinResult.parse(coin)
return parsedData
})
})
you can probably add something like error handling etc
18 replies
TTCTheo's Typesafe Cult
Created by Simvolick on 3/7/2023 in #questions
Any resources to learn the tRPC better? Hopefully with guides and examples?
What are the things that you find confusing
18 replies
TTCTheo's Typesafe Cult
Created by noctate on 3/6/2023 in #questions
How to type object like this as props
https://create.t3.gg/en/usage/trpc/#optimistic-updates i just copied example from the docs to use optimistic updates. I wanted to pass it as props because too different components use this add todo, so didnt wanted repeat myself. For now I choosed to extract all logic inside useTodos hook and just use it something like this:
const CreateTodo = () => {
const {addTodo} = useTodos();
}
const CreateTodo = () => {
const {addTodo} = useTodos();
}
6 replies
TTCTheo's Typesafe Cult
Created by jonnyfapson on 3/1/2023 in #questions
How to handle color codes in (medium-big) projects?
Maybe this talk will give you some ideas https://youtu.be/T-Zv73yZ_QI
6 replies
TTCTheo's Typesafe Cult
Created by noctate on 2/27/2023 in #questions
docker lags my pc
yeah I use planetscale right now, great stuff. Will try cockroach too in future probably
16 replies
TTCTheo's Typesafe Cult
Created by noctate on 2/27/2023 in #questions
docker lags my pc
thx guys, i guess i will just pass on it for now, and try when I have more RAM 😄 I didn't feel like I needed to use Docker with T3 anyway, just was curious
16 replies
TTCTheo's Typesafe Cult
Created by noctate on 1/9/2023 in #questions
how to delete post if it has likes
oh just reading prisma docs it seems like i need to do something like this
const deletePosts = prisma.post.deleteMany({
where: {
authorId: 7,
},
})

const deleteUser = prisma.user.delete({
where: {
id: 7,
},
})

const transaction = await prisma.$transaction([deletePosts, deleteUser])
const deletePosts = prisma.post.deleteMany({
where: {
authorId: 7,
},
})

const deleteUser = prisma.user.delete({
where: {
id: 7,
},
})

const transaction = await prisma.$transaction([deletePosts, deleteUser])
8 replies
TTCTheo's Typesafe Cult
Created by noctate on 1/5/2023 in #questions
reduce initial response time
thx for help anyway 😄
10 replies
TTCTheo's Typesafe Cult
Created by noctate on 1/5/2023 in #questions
reduce initial response time
hmm I played with it, changed the ssr to false, it seems to be better
10 replies
TTCTheo's Typesafe Cult
Created by noctate on 1/5/2023 in #questions
reduce initial response time
Yeah Im fetching the data from coingecko API
10 replies