GabrielC
GabrielC
DTDrizzle Team
Created by GabrielC on 1/4/2024 in #help
left join make the types never
Yes, that works perfect
10 replies
DTDrizzle Team
Created by GabrielC on 1/4/2024 in #help
left join make the types never
a solution can be this
export const baseTableColumns = {
id: int('id').primaryKey().autoincrement().notNull(),
updatedAt: timestamp('updated_at').onUpdateNow(),
createdAt: timestamp('created_at').defaultNow().notNull(),
deletedAt: timestamp('deleted_at')
}

export const sentReminderTable = mysqlTable('sent_reminder', {
...baseTableColumns,
reminderId: int('reminder_id').references(() => reminderTable.id).notNull(),
invoiceId: int('invoice_id').references(() => invoiceTable.id).notNull(),
notificationType: mysqlEnum('notification_type', reminderNotificationType).notNull(),
familyMemberId: int('family_member_id').references(() => familyMemberTable.id).notNull(),
sentAt: timestamp('sent_at').notNull(),
});
export const baseTableColumns = {
id: int('id').primaryKey().autoincrement().notNull(),
updatedAt: timestamp('updated_at').onUpdateNow(),
createdAt: timestamp('created_at').defaultNow().notNull(),
deletedAt: timestamp('deleted_at')
}

export const sentReminderTable = mysqlTable('sent_reminder', {
...baseTableColumns,
reminderId: int('reminder_id').references(() => reminderTable.id).notNull(),
invoiceId: int('invoice_id').references(() => invoiceTable.id).notNull(),
notificationType: mysqlEnum('notification_type', reminderNotificationType).notNull(),
familyMemberId: int('family_member_id').references(() => familyMemberTable.id).notNull(),
sentAt: timestamp('sent_at').notNull(),
});
10 replies
DTDrizzle Team
Created by GabrielC on 1/4/2024 in #help
left join make the types never
do you know how can i do this in another way? bc all my tables need this columns so in order to not write it in every table i did this
10 replies
DTDrizzle Team
Created by GabrielC on 1/4/2024 in #help
left join make the types never
but im not sure whhy bc im returnin a mysqlTable inside the function
10 replies
DTDrizzle Team
Created by GabrielC on 1/4/2024 in #help
left join make the types never
but yes that helperls is the problem i see, if i dont use that it works
10 replies
DTDrizzle Team
Created by GabrielC on 1/4/2024 in #help
left join make the types never
i use this helper baseMysqlTable bc all my tables use this id, updatedAt, createdAt, etc
10 replies
DTDrizzle Team
Created by GabrielC on 1/4/2024 in #help
left join make the types never
i'm definding the table in this way
const baseMysqlTable = <TColumnsMap extends Record<string, MySqlColumnBuilder>>(name: string, columns: TColumnsMap) => {
return mysqlTable(name, {
id: int('id').primaryKey().autoincrement().notNull(),
updatedAt: timestamp('updated_at').onUpdateNow(),
createdAt: timestamp('created_at').defaultNow().notNull(),
deletedAt: timestamp('deleted_at'),
...columns,
});
};

export default baseMysqlTable;

export const sentReminderTable = baseMysqlTable('sent_reminder', {
reminderId: int('reminder_id').references(() => reminderTable.id).notNull(),
invoiceId: int('invoice_id').references(() => invoiceTable.id).notNull(),
notificationType: mysqlEnum('notification_type', reminderNotificationType).notNull(),
familyMemberId: int('family_member_id').references(() => familyMemberTable.id).notNull(),
sentAt: timestamp('sent_at').notNull(),
});
const baseMysqlTable = <TColumnsMap extends Record<string, MySqlColumnBuilder>>(name: string, columns: TColumnsMap) => {
return mysqlTable(name, {
id: int('id').primaryKey().autoincrement().notNull(),
updatedAt: timestamp('updated_at').onUpdateNow(),
createdAt: timestamp('created_at').defaultNow().notNull(),
deletedAt: timestamp('deleted_at'),
...columns,
});
};

export default baseMysqlTable;

export const sentReminderTable = baseMysqlTable('sent_reminder', {
reminderId: int('reminder_id').references(() => reminderTable.id).notNull(),
invoiceId: int('invoice_id').references(() => invoiceTable.id).notNull(),
notificationType: mysqlEnum('notification_type', reminderNotificationType).notNull(),
familyMemberId: int('family_member_id').references(() => familyMemberTable.id).notNull(),
sentAt: timestamp('sent_at').notNull(),
});
10 replies
DTDrizzle Team
Created by GabrielC on 11/26/2023 in #help
Mysql JSON_ARRAYAGG as a string instead of a json
that works perfect thanks
3 replies
DTDrizzle Team
Created by GabrielC on 9/25/2023 in #help
How can I get a type from SelectedFields<MySqlColumn, Table>?
hi @Dan Kochetov the issue is already created by another user https://github.com/drizzle-team/drizzle-orm/issues/637
18 replies
DTDrizzle Team
Created by GabrielC on 9/25/2023 in #help
How can I get a type from SelectedFields<MySqlColumn, Table>?
No description
18 replies
DTDrizzle Team
Created by GabrielC on 9/25/2023 in #help
How can I get a type from SelectedFields<MySqlColumn, Table>?
yes i tried that but is now working for me
18 replies
DTDrizzle Team
Created by GabrielC on 9/25/2023 in #help
How can I get a type from SelectedFields<MySqlColumn, Table>?
18 replies
DTDrizzle Team
Created by GabrielC on 9/25/2023 in #help
How can I get a type from SelectedFields<MySqlColumn, Table>?
how to import it in my code
18 replies
DTDrizzle Team
Created by GabrielC on 9/25/2023 in #help
How can I get a type from SelectedFields<MySqlColumn, Table>?
18 replies
DTDrizzle Team
Created by GabrielC on 9/25/2023 in #help
How can I get a type from SelectedFields<MySqlColumn, Table>?
that looks really good but I am no able to import that type on my code, i'm using drizzle-orm 0.28.6 how can i import that type?
18 replies
DTDrizzle Team
Created by GabrielC on 5/4/2023 in #help
Error types with custom schema
I'm trying to do something like this now
const baseMysqlTable = <TColumnsMap extends Record<string, AnyMySqlColumnBuilder>>(name: string, columns: TColumnsMap) => {
return mysqlTable(name, {
...columns,
id: int('id').primaryKey().autoincrement().notNull(),
updatedAt: timestamp('updated_at').onUpdateNow(),
createdAt: timestamp('created_at').defaultNow(),
deletedAt: timestamp('deleted_at')
});
};

type BaseMysqlTableType = ReturnType<typeof baseMysqlTable>;

const withPagination = async <S extends AnyMySqlSelect, T extends AnyMySqlTable<BaseMysqlTableType>> (qb: S, table: T, offset = 0, limit = 10) => {
const data = await qb.offset(offset).limit(limit).orderBy(desc(table.id));
const count = await db.select({}).from(table);
return {
data,
offset,
limit,
// total: count[0]
}
}
const baseMysqlTable = <TColumnsMap extends Record<string, AnyMySqlColumnBuilder>>(name: string, columns: TColumnsMap) => {
return mysqlTable(name, {
...columns,
id: int('id').primaryKey().autoincrement().notNull(),
updatedAt: timestamp('updated_at').onUpdateNow(),
createdAt: timestamp('created_at').defaultNow(),
deletedAt: timestamp('deleted_at')
});
};

type BaseMysqlTableType = ReturnType<typeof baseMysqlTable>;

const withPagination = async <S extends AnyMySqlSelect, T extends AnyMySqlTable<BaseMysqlTableType>> (qb: S, table: T, offset = 0, limit = 10) => {
const data = await qb.offset(offset).limit(limit).orderBy(desc(table.id));
const count = await db.select({}).from(table);
return {
data,
offset,
limit,
// total: count[0]
}
}
but still dosen't work
5 replies
DTDrizzle Team
Created by GabrielC on 4/12/2023 in #help
Problem running a migration
thanks u so much, that works
4 replies