export const users = mysqlTable("users", {
id: serial("id").primaryKey(),
username: varchar("username", { length: 120 }),
});
export const blocks = mysqlTable("blocks", {
id: serial("id").primaryKey(),
block_type: int("type"),
user_id: int("user_id"),
});
export const usersRelations = relations(users, ({ many }) => ({
pagebuilder: many(blocks),
}));
(async () => {
const user = await db.query.users.findFirst({
where: eq(users.username, "johnsmith"),
with: {
pagebuilder: true,
},
});
// user.pagebuilder[0].block_type ☑️
})();
export const users = mysqlTable("users", {
id: serial("id").primaryKey(),
username: varchar("username", { length: 120 }),
});
export const blocks = mysqlTable("blocks", {
id: serial("id").primaryKey(),
block_type: int("type"),
user_id: int("user_id"),
});
export const usersRelations = relations(users, ({ many }) => ({
pagebuilder: many(blocks),
}));
(async () => {
const user = await db.query.users.findFirst({
where: eq(users.username, "johnsmith"),
with: {
pagebuilder: true,
},
});
// user.pagebuilder[0].block_type ☑️
})();