thebjorn
thebjorn
Explore posts from servers
DTDrizzle Team
Created by thebjorn on 4/6/2025 in #help
Is it possible to introspect relations?
Let's say I have the following relation def:
export const externalUsersRelations = relations(external_users, ({one}) => ({
users: one(users, {
fields: [external_users.user_id],
references: [users.id]
})
}));
export const externalUsersRelations = relations(external_users, ({one}) => ({
users: one(users, {
fields: [external_users.user_id],
references: [users.id]
})
}));
is there any way I can write a function that returns the config object?, i.e.
function one_relations(r) {...}
one_relations(external_usersRelations) // returning [['one', users, {fields:.., references: ..}], ...]
function one_relations(r) {...}
one_relations(external_usersRelations) // returning [['one', users, {fields:.., references: ..}], ...]
1 replies
DTDrizzle Team
Created by thebjorn on 6/4/2024 in #help
I cant get Drizzle with Queries to work...
I'm converting a project from prisma, and I'm a bit stuck on the simplest of queries... This returns records:
await db.query.Session.findMany({})
await db.query.Session.findMany({})
while this:
await db.query.Session.findMany({
with: {User: true}
})
await db.query.Session.findMany({
with: {User: true}
})
throws TypeError: Cannot read properties of undefined (reading 'referencedTable') The Session table:
export const Session = pgTable("Session", {
sessionToken: text("sessionToken").notNull(),
userId: text("userId").notNull().references(() => User.id, { onDelete: "cascade", onUpdate: "cascade" } ),...
export const Session = pgTable("Session", {
sessionToken: text("sessionToken").notNull(),
userId: text("userId").notNull().references(() => User.id, { onDelete: "cascade", onUpdate: "cascade" } ),...
The User table:
export const User = pgTable("User", {
id: text("id").primaryKey().notNull(),
...
export const User = pgTable("User", {
id: text("id").primaryKey().notNull(),
...
(there was also a relations.ts file created during introspection that is not imported anywhere) I'm sure I've just missed something in the documentation, but I've been stuck on this for almost a day now.
3 replies
KPCKevin Powell - Community
Created by thebjorn on 4/16/2024 in #front-end
How are inline-block vertically aligned?
Given the html
<section>
<div class="a"></div>
<div class="b">b</div>
<div class="c"></div>
</section>
<section>
<div class="a"></div>
<div class="b">b</div>
<div class="c"></div>
</section>
and the css
div {
width: 2rem;
aspect-ratio: 1;
margin: .5rem;
background-color: rebeccapurple; color: white;
display: inline-block;
}
div {
width: 2rem;
aspect-ratio: 1;
margin: .5rem;
background-color: rebeccapurple; color: white;
display: inline-block;
}
I would expect the 3 divs to line up horizontally, yet they do not: https://codepen.io/bjorn-pettersen/pen/xxeaaEg What am I missing?
3 replies