Last active
August 23, 2023 03:48
-
-
Save mkanenobu/f3b0f766f6648b131cc387a68cb7320d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const datetimeWithTZ = <T extends ColumnBaseConfig>( | |
column: MySqlDateTimeString<T> | |
) => | |
sql`DATE_FORMAT(${column}, '%Y-%m-%dT%TZ')`.mapWith((v) => new Date(v)); | |
// example | |
// await db.select({ createdAt: datetimeWithTz(table.createdAt) }).from(table); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment