IgnisMurasaki
IgnisMurasaki
DTDrizzle Team
Created by IgnisMurasaki on 7/10/2024 in #help
A more modular way to combine predefined query into a single transaction
Thankyou very much, it's very helpfull for me. it's really helping me a lot
3 replies
DTDrizzle Team
Created by alka_99 on 2/10/2024 in #help
Cant query with relation using query method
ah sorry, i forgot to informing about this, it turns out that I have to add the relations variables when creating initializing the drizzle it's been solved now
6 replies
DTDrizzle Team
Created by IgnisMurasaki on 3/18/2024 in #help
having trouble to include relations with query function
turns out yes it's, I didn't include the relation when creating the drizzle instance
5 replies
DTDrizzle Team
Created by IgnisMurasaki on 3/18/2024 in #help
having trouble to include relations with query function
am i missing something, is this relation variable should be assigned somewhere ?
5 replies
DTDrizzle Team
Created by alka_99 on 2/10/2024 in #help
Cant query with relation using query method
OP, sorry for necroing this post, but I'm also having trouble with the include relations query, what should be the property inside the with object ? my relation is declared like the following
export const eventsRelations = relations(events, ({ many, one }) => ({
host: one(users, {
fields: [events.createdBy],
references: [users.id],
}),
}));

export const usersRelations = relations(users, ({ many }) => ({
events: many(events),
}));
export const eventsRelations = relations(events, ({ many, one }) => ({
host: one(users, {
fields: [events.createdBy],
references: [users.id],
}),
}));

export const usersRelations = relations(users, ({ many }) => ({
events: many(events),
}));
and here's the query
async getEventBySlug(slug: string): Promise<selectEvent | undefined> {
const data = await db.query.events.findFirst({
with: { host: true },
where: and(eq(events.slug, slug), isNull(events.deletedAt)),
});

if (data) return data as selectEvent;
else return undefined;
}
async getEventBySlug(slug: string): Promise<selectEvent | undefined> {
const data = await db.query.events.findFirst({
with: { host: true },
where: and(eq(events.slug, slug), isNull(events.deletedAt)),
});

if (data) return data as selectEvent;
else return undefined;
}
i've also tried to change the with object to {users:true} but still receiving the referencedTable error
6 replies