const schema1 = mysqlSchema('schema1');
const schema2 = mysqlSchema('schema2');
const table_a = schema1.table('table_a', {
id: int('id'),
});
const table_b = schema2.table('table_b', {
id: int('id'),
tblA_ref: int('a_ref').references(() => table_a.id),
});
const tbl_b_relations = relations(table_b, ({ one }) => ({
tblA: one(...)
});
const schema = { table_a, table_b, tbl_b_relations };
const poolConnection = mysql.createPool(...);
const db = drizzle(poolConnection, {
...,
schema
});
const results = db.query.table_b.findMany({
with: {
tblA: true
},
});
const schema1 = mysqlSchema('schema1');
const schema2 = mysqlSchema('schema2');
const table_a = schema1.table('table_a', {
id: int('id'),
});
const table_b = schema2.table('table_b', {
id: int('id'),
tblA_ref: int('a_ref').references(() => table_a.id),
});
const tbl_b_relations = relations(table_b, ({ one }) => ({
tblA: one(...)
});
const schema = { table_a, table_b, tbl_b_relations };
const poolConnection = mysql.createPool(...);
const db = drizzle(poolConnection, {
...,
schema
});
const results = db.query.table_b.findMany({
with: {
tblA: true
},
});