joostschuur
DTDrizzle Team
•Created by joostschuur on 2/18/2025 in #help
Directly accessing array of many to many relationship properties through junction table
Thank you for coming to my TED talk
7 replies
DTDrizzle Team
•Created by joostschuur on 2/18/2025 in #help
Directly accessing array of many to many relationship properties through junction table
Well, answering more of my own question, looks like
through
is coming in the Relational API v2
https://github.com/drizzle-team/drizzle-orm/discussions/23167 replies
DTDrizzle Team
•Created by joostschuur on 2/18/2025 in #help
Directly accessing array of many to many relationship properties through junction table
So then each row looks like this:
7 replies
DTDrizzle Team
•Created by joostschuur on 2/18/2025 in #help
Directly accessing array of many to many relationship properties through junction table
So basically
7 replies
DTDrizzle Team
•Created by joostschuur on 2/18/2025 in #help
Directly accessing array of many to many relationship properties through junction table
Looks like this is discussed here as a new feature, so for now, I would have to do a wrapper an remove the nesting myself:
https://github.com/drizzle-team/drizzle-orm/issues/2933
7 replies
DTDrizzle Team
•Created by joostschuur on 2/18/2025 in #help
Directly accessing array of many to many relationship properties through junction table
I can run
db.query.cardsTable.findMany({ with: { vocabulary: { with: { vocabulary } })
and in the resulting rows vocabulary.vocabulary
has an array of he actual vocabulary fields, but I'd prefer it just be a single vocabulary
entry with the actual array.
If I just run db.query.cardsTable.findMany({ with: { vocabulary: true })
, then vocabulary
is an array of cardId
and vocabularyId
.7 replies
DTDrizzle Team
•Created by joostschuur on 3/14/2024 in #help
Error: Cannot find module '@libsql/darwin-arm64' when using Drizzle/SST
Looks like it's an issue with recent versions of @libsql/client per https://github.com/tursodatabase/libsql-client-ts/issues/112
I downgraded to @libsql/client 0.3.3 and it worked.
3 replies
DTDrizzle Team
•Created by joostschuur on 3/14/2024 in #help
Error: Cannot find module '@libsql/darwin-arm64' when using Drizzle/SST
This also seems to happen without using a monorepo, when I have drizzle setup and schema files locally and all the right dependencies installed.
3 replies
DTDrizzle Team
•Created by joostschuur on 2/13/2024 in #help
Using Drizzle SQLite in a Next.js server component gives error that suggests client side execution
Thanks! The original idea for the site was to produce community managed shared playlists of content that could help people find the right combination of videos for specific use cases.
Like '5 Videos to Really Help You Understand Server Components' 😉
I'm going to start looking at strategies for search and I also want to start using AI to build category tags. Will check that article out too. Big work project keeping me busy right now...
26 replies
DTDrizzle Team
•Created by joostschuur on 2/13/2024 in #help
Using Drizzle SQLite in a Next.js server component gives error that suggests client side execution
I'm working on a site that indexes dev videos (https://beta.learnbyvideo.dev/), so I come across this a lot where the video title is English, but the video will be primarily what I presume is Hindi.
26 replies
DTDrizzle Team
•Created by joostschuur on 2/13/2024 in #help
Using Drizzle SQLite in a Next.js server component gives error that suggests client side execution
It always fascinates me to hear Indians mix English and Hindi like this. I grew up in Germany and you'd see the parents talk to their kids in Turkish and the kids speak German back, but this is different. My Indian flatmate used to do this on the phone too.
I have the sudden urge to go down a rabbit hole and read up on how this evolved (spoiler alert: colonialism?) and the modern psychology behind it. But I have work to do!
26 replies
DTDrizzle Team
•Created by joostschuur on 2/13/2024 in #help
Using Drizzle SQLite in a Next.js server component gives error that suggests client side execution
Also, thanks for pointing me to your example, @deadcoder0904!
26 replies
DTDrizzle Team
•Created by joostschuur on 2/13/2024 in #help
Using Drizzle SQLite in a Next.js server component gives error that suggests client side execution
@Isaiah Smith This was all super useful, thanks. I thought I understood server components but I guess I didn't.
The way you explained the importing/bundling aspect helped me understand the problems and why passing the server component in as children props helps.
Thanks again for taking the time to elaborate on this. Going to do some more reading on what happens under the hood, especially in Next.js 14.
26 replies
DTDrizzle Team
•Created by joostschuur on 2/13/2024 in #help
Using Drizzle SQLite in a Next.js server component gives error that suggests client side execution
Same thing when I use Drizzle && Postgres. I'm starting to wonder if Drizzle works in a server component at all. (Next.js app directory)
26 replies
DTDrizzle Team
•Created by joostschuur on 2/13/2024 in #help
Using Drizzle SQLite in a Next.js server component gives error that suggests client side execution
Eventually the results of a server component get rehydrated somehow, right? Could that be related?
26 replies
DTDrizzle Team
•Created by joostschuur on 2/13/2024 in #help
Using Drizzle SQLite in a Next.js server component gives error that suggests client side execution
This specifically seems to happen when a client component includes a server component that makes a Drizzle call.
Sample repo: https://github.com/jschuur/drizzle-turso-test
Remove the
use client
from page.tsx
and it runs fine.
The error above shows up in both the browser and the terminal, which suggests that despite being made in a server component, it's running in the client?
Even if I swap out Turso's @libsql/client
with better-sqlite3
I get an error about the fs
module suggesting yet again something is being run on the client side.
However, if I remove any Drizzle call from the ListSurvey
server component and just use a hardcoded array, I get no error and it definitely ran on the server.
I don't know under what circumstances a server component might still run code in the browser, but this looks like it might be related to Drizzle?26 replies
DTDrizzle Team
•Created by joostschuur on 9/9/2023 in #help
Updating with a subquery
But it works 🙂
34 replies
DTDrizzle Team
•Created by joostschuur on 9/9/2023 in #help
Updating with a subquery
Naming the field
max
, but still having lastPublishedAt:
work like that without a .max
definitely looks counterintuitive for a novice to the API like it.
I also hadn't thought about putting a whole db...
chain into a sql
call like that, especially without it ending in a .toSQL()
.34 replies
DTDrizzle Team
•Created by joostschuur on 9/9/2023 in #help
Updating with a subquery
Almost. Just needed a tweak:
.where(eq(feedItems.feedId, feeds.id))
Thanks for writing this up, especially with the detailed notes! I've been using Prisma for so long, my SQL skills have atrophied 🙂34 replies
DTDrizzle Team
•Created by joostschuur on 9/9/2023 in #help
Updating with a subquery
Honestly, I just can't wrap my head around the Drizzle syntax
34 replies