Dane
Dane
Explore posts from servers
DTDrizzle Team
Created by Dane on 8/8/2024 in #help
drizzle connection missing schema types
schema itself has all the correct types, it just isn't being passed through to the db constant
9 replies
DTDrizzle Team
Created by Dane on 8/8/2024 in #help
drizzle connection missing schema types
"database" is pointing to a package inside a turborepo monorepo
9 replies
DTDrizzle Team
Created by Dane on 8/8/2024 in #help
drizzle connection missing schema types
ignore the .firstName() part...
9 replies
DTDrizzle Team
Created by sayuto on 8/6/2024 in #help
DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB typ
9 replies
DTDrizzle Team
Created by sayuto on 8/6/2024 in #help
DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB typ
This doesn't seem to work with the planetscale-serverless driver
9 replies
DTDrizzle Team
Created by Happer64Bit on 6/21/2024 in #help
is there a way to use Redis in drizzle
You can't use connect to redis from the drizzle-orm though
4 replies
DTDrizzle Team
Created by Happer64Bit on 6/21/2024 in #help
is there a way to use Redis in drizzle
You would need to wrap your query in a some sort of caching function, then return as the tables inferSelect type:
export function getUser(id: number) {
const cachedUser = await redis.get(`user:${id}`)
if (cachedUser) return JSON.parse(cachedUser) as userTable.$inferSelect
const user = await db.query.userTable.findFirst({ where: eq(userTable.id, id) })
redis.setex(`user:${id}`, 100, JSON.stringify(user))
return user
}
export function getUser(id: number) {
const cachedUser = await redis.get(`user:${id}`)
if (cachedUser) return JSON.parse(cachedUser) as userTable.$inferSelect
const user = await db.query.userTable.findFirst({ where: eq(userTable.id, id) })
redis.setex(`user:${id}`, 100, JSON.stringify(user))
return user
}
4 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
the docs on drizzle for cascade events aren't really there... in mysql the drizzle schema is this, i would imagine the same for postgres:
productId: int("productId").references(() => products.id, {
onDelete: "cascade",
onUpdate: "cascade",
})
productId: int("productId").references(() => products.id, {
onDelete: "cascade",
onUpdate: "cascade",
})
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
looks like it's called DROP CASCADE in postgres
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
You shouldn't need a trigger to accomplish that
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
the promptTagLink.tagId would be a foreign key of tag.id , so deleting the tag would trigger a cascade event deleting any promptTagLink rows with the same tag id
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
I imagine the same is possible with postgres
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
I am more familiar with MySQL, an "on delete cascade" in MySQL would accomplish that
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
Are you using MySQL?
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
No description
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
No description
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
I have a similar setup linking products available to a program through an intermediate programProductLink table:
50 replies
DTDrizzle Team
Created by king.edwards on 9/13/2023 in #help
Help with improving database query
@king.edwards Each tag would be added as it's own row in the tags table instead of being in an array in a single row. prompt -> one-to-many -> tags If you wanted a standardized list of tags and then linking those to a prompt you would want: prompt <- one-to-one tagsAssignedToPrompt one-to-one -> tags tagsAssignedToPrompt would be an intermediate table containing the fields promptId and tagId. You would have one row for each promptId+tagId connection
50 replies