yoggyd
yoggyd
Explore posts from servers
DTDrizzle Team
Created by yoggyd on 9/21/2023 in #help
totalCount from relational query
is it somehow possible to get the total count of a relational query? Core queries aren't possible here due to a bug in how drizzle builds the column identifiers (multiple columns have the same name here and duplicates are discarded, resulting in undefined values) I thought maybe I could utilize CTEs here but then how would I get the benefit of relational queries? Is string manipulation really the only option here?
1 replies
DTDrizzle Team
Created by yoggyd on 9/19/2023 in #help
many to many self reference
I'm trying to define "follows" & "followers" relations on a user entity. Obviously this is a many to many relation, but how to I define both "edges" in my relation?
const userToUsers = table("users", {
userId: text(),
followsUserId: text(),
}); // rather pseudo-ish code

const userRelations = relations(users, ({many}) => ({
follows: many(userToUsers),
followers: many(userToUsers), // hmmm... distinct from follows how?
}));
const userToUsers = table("users", {
userId: text(),
followsUserId: text(),
}); // rather pseudo-ish code

const userRelations = relations(users, ({many}) => ({
follows: many(userToUsers),
followers: many(userToUsers), // hmmm... distinct from follows how?
}));
I've seen many takes a config param relationName but I don't see where I can define that the relation "follows" references followsUserId and "followers" references userId?
10 replies
DTDrizzle Team
Created by yoggyd on 8/14/2023 in #help
sqlite code first with in-memory db
Hey, I thought it'd be rather easy to create a schema from scratch without running a "migration" (from nothing to v1 is a migration?), but apparently I was wrong. I'm using bun:sqlite and would prefer to not create some migration files or whatever. Shouldn't db.run(table.getSql()) work? Is there even an option to bootstrap a schema without creating additional files?
1 replies