! AlexNotTheLion
! AlexNotTheLion
Explore posts from servers
TTCTheo's Typesafe Cult
Created by ! AlexNotTheLion on 6/24/2024 in #questions
conditional rendering with url search params and server side data fetching with nextjs 14
I have a modal which is shown based on url params "?modal=friends", I would like to use as much server side data fetching as possible as it makes a nicer user experience, the modal should fetch the users friend list from supabase and then conditionally render either a dialog for desktop or a drawer for mobile (both shadcn components), ideally id like to avoid waterfalling components. so far I've tried. 1. parallel routes (completely broken and don't hot reload on changes, i had to completely restart the dev server to see changes) 2. doing client side data fetching which is slow and only fetches on render, i would like to fetch the data before the dialog / drawer is mounted the questions i have are: 1. is there a way around this without having a really gross waterfall architecture 2. are parallel routes just completely the wrong thing here as i dont actually have routes to navigate to 3. am i just being a moron and theres something completely different i should be doing instead
1 replies
TTCTheo's Typesafe Cult
Created by ! AlexNotTheLion on 6/21/2024 in #questions
In Nextjs how do you set serachParams in middleware ?
No description
17 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 4/2/2024 in #help
friendship query that returns the other user object
I have two tables:
friendships:{id:uuid, sender: uuid, target: uuid, status: enum("accepted","pending")}
friendships:{id:uuid, sender: uuid, target: uuid, status: enum("accepted","pending")}
and
profiles:{id:uuid, username:string}
profiles:{id:uuid, username:string}
I want to query the friendships table for the local user id from the supabase client (supabase auth table syncs rows to the profiles table), and return an object like {id:friendship.id, status:friendship.status, user:profile} where the user is the other user, unfortunately most ai coding assistants dont have full or up to date knowledge of drizzle orms (including the one on the drizzle docs site) so is this possible with just drizzle syntax's and how can i do this ?
8 replies
TTCTheo's Typesafe Cult
Created by ! AlexNotTheLion on 3/20/2024 in #questions
NextAuth.js (Auth.js) vs SuapbaseAuth
Working on a side / portfolio project and I was using Planetscale until they nuked their free tier so i moved to supabase (which i really like so far, no need to spin up drizzle kit studio to edit tables). I was also using Clerk but ran quickly into an issue where i wanted to include all the users related to a query and couldn't easily get user data without having to do multiple queries, one solution would be to use webhooks to "sync" data between supabase and clerk. This led me to supabase auth, useful user management interface, also automatically syncs with a users/profile table if I want thanks to database functions, good cascading options, and also allowed me to use more providers than clerks default 3 (for the free tier at least), after poking around and doing some googling I noticed lots of people recommended next auth / auth.js over supabase auth, however most of the results I found are at least a year old or more and it appears supabase has changed a lot since then. So what are the arguments for NextAuth.js (Auth.js) vs Supabase Auth as of March of 2024 ?
9 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 2/19/2024 in #help
(Solved) Filter where json array contains
I have a json array of strings, an invite list of user ids (clerk is managing my users which is why its not a relation), im trying to get all results from the events table where the current users id is in the invite list or the host, using planetscale (mysql) and i cannot figure out the correct syntax this is what i have so far
const user = await currentUser();
if (user === null) return [];

const query = await db.query.events.findMany({
where: or(eq(events.user_id, user.id), inArray(events.invited_users, [user.id]))
});
const user = await currentUser();
if (user === null) return [];

const query = await db.query.events.findMany({
where: or(eq(events.user_id, user.id), inArray(events.invited_users, [user.id]))
});
and this is the schema for the events table
export const events = mysqlTable('event', {
id: serial('id').primaryKey(),
user_id: text('user_id').notNull(),
start: timestamp('start', { mode: 'date' }).defaultNow().notNull(),
end: timestamp('end', { mode: 'date' }).defaultNow().notNull(),
title: varchar('title', { length: 50 }),
description: varchar('description', { length: 500 }).default(""),
invited_users: json("invited_users").$type<string[]>().default([]),
});
export const events = mysqlTable('event', {
id: serial('id').primaryKey(),
user_id: text('user_id').notNull(),
start: timestamp('start', { mode: 'date' }).defaultNow().notNull(),
end: timestamp('end', { mode: 'date' }).defaultNow().notNull(),
title: varchar('title', { length: 50 }),
description: varchar('description', { length: 500 }).default(""),
invited_users: json("invited_users").$type<string[]>().default([]),
});
6 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 11/7/2023 in #help
[Solved] cannot find package 'mysql2'
I've setup drizzle with a planetscale db and pushed a simple user schema, however running the pnpm drizzle-kit studio command as indicated in the docs comes back with the following error
Cannot find package 'mysql2' imported from C:\Users\username\Desktop\testProj\node_modules\.pnpm\[email protected]_@[email protected]\node_modules\drizzle-orm\mysql2\index.mjs
Cannot find package 'mysql2' imported from C:\Users\username\Desktop\testProj\node_modules\.pnpm\[email protected]_@[email protected]\node_modules\drizzle-orm\mysql2\index.mjs
does anyone know why ?
2 replies