Blume
Blume
Explore posts from servers
DTDrizzle Team
Created by Blume on 1/22/2025 in #help
drizzle-kit studio reading .env file
Hmm the linked issue comment unfortunately won't solve our problem.. loadEnvConfig from next/env still will treat every already existing env var as highest priority and not override it.. I fear the only viable solution would be to prevent drizzle from loading the .env by itself and give full controll to the developers.. But sounds like thats not a priority for them
5 replies
DTDrizzle Team
Created by Blume on 1/22/2025 in #help
drizzle-kit studio reading .env file
Thank you! I'll have a look :) We solved it for now by omitting the problematic env vars in our normal .env..
5 replies
DTDrizzle Team
Created by Blume on 1/22/2025 in #help
drizzle-kit studio reading .env file
bump
5 replies
DTDrizzle Team
Created by Blume on 10/15/2023 in #help
Use column name in like operator
I was able to solve it via
or(eq(tagsWithNoteIds.tag, Tags.tag), sql`${tagsWithNoteIds.tag} LIKE ${Tags.tag} || '%'`)
or(eq(tagsWithNoteIds.tag, Tags.tag), sql`${tagsWithNoteIds.tag} LIKE ${Tags.tag} || '%'`)
Not as pretty but does the job
2 replies
DTDrizzle Team
Created by Blume on 10/14/2023 in #help
many-to-many query with where filter on second level
I was able to solve it with
const selectTags = DB.$with("sq").as(
DB.select({ noteId: NotesToTags.noteId, tags: sql<string[]>`array_agg(${Tags.tag})`.as("tags") })
.from(NotesToTags)
.leftJoin(Tags, eq(Tags.id, NotesToTags.tagId))
.where(like(Tags.tag, `${query.tag ?? ""}%`))
.groupBy(NotesToTags.noteId),
);

const result = await DB.with(selectTags)
.select()
.from(Notes)
.innerJoin(selectTags, eq(selectTags.noteId, Notes.id))
.where(and(eq(Notes.authorId, query.authorId)));
const selectTags = DB.$with("sq").as(
DB.select({ noteId: NotesToTags.noteId, tags: sql<string[]>`array_agg(${Tags.tag})`.as("tags") })
.from(NotesToTags)
.leftJoin(Tags, eq(Tags.id, NotesToTags.tagId))
.where(like(Tags.tag, `${query.tag ?? ""}%`))
.groupBy(NotesToTags.noteId),
);

const result = await DB.with(selectTags)
.select()
.from(Notes)
.innerJoin(selectTags, eq(selectTags.noteId, Notes.id))
.where(and(eq(Notes.authorId, query.authorId)));
2 replies
DTDrizzle Team
Created by ippo on 9/15/2023 in #help
TRIGGERS in Drizzle
Thanks!
13 replies
DTDrizzle Team
Created by ippo on 9/15/2023 in #help
TRIGGERS in Drizzle
Hmm I see, I'm not yet using migration files (Early project) but maybe I can use a custom migration file for stuff like that
13 replies
DTDrizzle Team
Created by ippo on 9/15/2023 in #help
TRIGGERS in Drizzle
Have you been able to do it? I have no Idea how I would do this in the schema file... And how would drizzle-kit know how to write the migration when using plain SQL? A drizzle-native way to add triggers would be really cool
13 replies