rykuno
rykuno
Explore posts from servers
HHono
Created by rykuno on 10/20/2024 in #help
Envs not extendable with `createFactory`
in the screenshot examples, I have one working example(without factory) and one broken(with factory).
2 replies
DDeno
Created by Siki on 10/10/2024 in #help
Deno workspace with sveltekit(package.json) import native deno library dependency
also having this issue.
7 replies
DTDrizzle Team
Created by rykuno on 8/26/2023 in #help
Optional/Default value for Relational `Extras`
SQL default mechanism ?? Odd, is this the latest drizzle orm version? It works for me on the latest typescript/drizzle version but still yields a type error. I just set an ignore for it atm
9 replies
DTDrizzle Team
Created by rykuno on 8/26/2023 in #help
Optional/Default value for Relational `Extras`
const event = await db.query.events.findFirst({
where: eq(events.id, params.eventId),
extras(fields, operators) {
return {
authedUserTicketId:
sql<string>`(SELECT (ticket_id) from ${members} where event_id = ${
fields.id
} and user_id = ${authedUser?.user.id || null})`.as(
'authed_user_membership'
)
};
},
with: {
tickets: {
extras(fields, operators) {
return {
memberCount:
sql<number>`(SELECT count(*)::int from ${members} where ticket_id = ${fields.id})`.as(
'member_count'
)
};
}
}
}
});
const event = await db.query.events.findFirst({
where: eq(events.id, params.eventId),
extras(fields, operators) {
return {
authedUserTicketId:
sql<string>`(SELECT (ticket_id) from ${members} where event_id = ${
fields.id
} and user_id = ${authedUser?.user.id || null})`.as(
'authed_user_membership'
)
};
},
with: {
tickets: {
extras(fields, operators) {
return {
memberCount:
sql<number>`(SELECT count(*)::int from ${members} where ticket_id = ${fields.id})`.as(
'member_count'
)
};
}
}
}
});
9 replies
DTDrizzle Team
Created by rykuno on 8/26/2023 in #help
Optional/Default value for Relational `Extras`
Tried that. Actually returns a TS error Type 'string' is not assignable to type 'Aliased<unknown>'.
9 replies
DTDrizzle Team
Created by rykuno on 7/14/2023 in #help
Soft Delete Strategy
My god, this library is maintained by absolute Chads
8 replies
TTCTheo's Typesafe Cult
Created by Lopen on 6/5/2023 in #questions
drizzle orm is overhyped
If you don't use serverless then use what you like??? I have two apps that utilize prisma that are hosted on Render.com; great performance. Yet it does suck incredibly on serverless apps, like, bad. Each has their pros and cons; but there's no arguing that if severless continues to increase in popularity then either prisma needs to figure out their cold starts or it will lose popularity pretty quickly. I'd love to use prisma on serverless apps but I cannot risk churn through 6 second cold starts vs Drizzle's 100ms
68 replies
DTDrizzle Team
Created by rykuno on 5/28/2023 in #help
Relation Query - Get likes in post
I've completed it like this at the moment, but man, im struggling to turn this into a relational query 😦
const author = alias(users, "author");
const hasLiked = alias(likes, "hasLiked");
const postRows = await db
.select({
likes: sql<number>`COUNT(${likes.id})`.as("likes"),
hasLiked: hasLiked,
post: posts,
author
})
.from(posts)
.where(eq(posts.eventId, params.id))
.leftJoin(likes, eq(likes.postId, posts.id))
.leftJoin(
hasLiked,
and(
eq(hasLiked.postId, posts.id),
eq(hasLiked.userId, session?.user?.id || "")
)
)
.innerJoin(author, eq(author.id, posts.authorId))
.orderBy(desc(posts.createdAt))
.groupBy(posts.id);
const author = alias(users, "author");
const hasLiked = alias(likes, "hasLiked");
const postRows = await db
.select({
likes: sql<number>`COUNT(${likes.id})`.as("likes"),
hasLiked: hasLiked,
post: posts,
author
})
.from(posts)
.where(eq(posts.eventId, params.id))
.leftJoin(likes, eq(likes.postId, posts.id))
.leftJoin(
hasLiked,
and(
eq(hasLiked.postId, posts.id),
eq(hasLiked.userId, session?.user?.id || "")
)
)
.innerJoin(author, eq(author.id, posts.authorId))
.orderBy(desc(posts.createdAt))
.groupBy(posts.id);
7 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
well the temporary work around is to just call it straight from a server component I guess. Im on 13.4.1 so I'll keep my eye out for a fix I suppose.
29 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
Server Actions cannot be defined within Client Components, but they can be imported. To use Server Actions in Client Components, you can import the action from a file containing a top-level "use server" directive.
Server Actions cannot be defined within Client Components, but they can be imported. To use Server Actions in Client Components, you can import the action from a file containing a top-level "use server" directive.
https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions#examples
29 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
According to their docs it should be 100% allowed.
29 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
I'm not the first to discover it apparently https://github.com/vercel/next.js/issues/49235
29 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
29 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
Its called on the client, but the action itself is a server action. Thus it shouldn't matter if a server or client component calls it so long as its done in the appropriate manner
29 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
This snippet when called from a form action within a client component will not have access to cookies; which seems wrong?
29 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
29 replies
TTCTheo's Typesafe Cult
Created by rykuno on 5/7/2023 in #questions
Next-Auth Session in Server Function
Its actually not a NextAuth issue I found out. The error was w/ accessing the browsers storage so I tried to access cookies just for fun
export async function createEvent(formData: FormData) {
"use server";
cookies().getAll();
}
export async function createEvent(formData: FormData) {
"use server";
cookies().getAll();
}
It gave the exact same error
29 replies