Hi, I am trying to set column type, which is used only for where clause. not for select.
Initially, I wrote it like this. but I encountered a type error on where clause.
export interface SomeTable {
id: Generated<number>
date: Date
// Other properties...
}
const result = await db.selectFrom('SomeTable')
.selectAll()
.where('date', '=', '2024-01-01') // type error
.limit(1)
.executeTakeFirst();
So I changed date: Date to date: ColumnType<Date | string>.
It works on where clause, but the result type is Date | string.
Consequently, result.date.getTime() doesn't working this time.
In my timezone "Asia/Tokyo", new Date('2024-01-01') will be converted to 2024-01-01 09:00:00.
Therefore, I would like to search in string, but get the result in Date.
Hi, I am trying to set column type, which is used only for where clause. not for select.
Initially, I wrote it like this. but I encountered a type error on where clause.
So I changed
date: Date
todate: ColumnType<Date | string>
. It works on where clause, but the result type isDate | string
. Consequently,result.date.getTime()
doesn't working this time.In my timezone "Asia/Tokyo",
new Date('2024-01-01')
will be converted to2024-01-01 09:00:00
. Therefore, I would like to search in string, but get the result in Date.Do you have any ideas for this? thanks.