netwrx
netwrx
Explore posts from servers
DTDrizzle Team
Created by netwrx on 4/18/2024 in #help
is it possible to do conditional relational queries?
for example, i only want to retrieve the author object if their profile is public (a boolean on a user object)
export const users_relations = relations(users_table, ({ many }) => ({
posts: many(posts_table),
}));

export const posts_relations = relations(posts_table, ({ one }) => ({
author: one(users_table, {
fields: [posts_table.owner_id],
references: [users_table.id],
}),
}));
export const users_relations = relations(users_table, ({ many }) => ({
posts: many(posts_table),
}));

export const posts_relations = relations(posts_table, ({ one }) => ({
author: one(users_table, {
fields: [posts_table.owner_id],
references: [users_table.id],
}),
}));
4 replies