Files
directus/api/src/database/helpers/date/dialects/mysql.ts
Oreille bc864d1f51 Improve helpers structure (#10052)
* Improve helpers structure

* Added DatabaseHelper base class

* Refactor index.ts
2021-12-01 15:08:24 -05:00

37 lines
1015 B
TypeScript

import { DateHelper } from '../types';
import { Knex } from 'knex';
export class DateHelperMySQL extends DateHelper {
year(table: string, column: string): Knex.Raw {
return this.knex.raw('YEAR(??.??)', [table, column]);
}
month(table: string, column: string): Knex.Raw {
return this.knex.raw('MONTH(??.??)', [table, column]);
}
week(table: string, column: string): Knex.Raw {
return this.knex.raw('WEEK(??.??)', [table, column]);
}
day(table: string, column: string): Knex.Raw {
return this.knex.raw('DAYOFMONTH(??.??)', [table, column]);
}
weekday(table: string, column: string): Knex.Raw {
return this.knex.raw('DAYOFWEEK(??.??)', [table, column]);
}
hour(table: string, column: string): Knex.Raw {
return this.knex.raw('HOUR(??.??)', [table, column]);
}
minute(table: string, column: string): Knex.Raw {
return this.knex.raw('MINUTE(??.??)', [table, column]);
}
second(table: string, column: string): Knex.Raw {
return this.knex.raw('SECOND(??.??)', [table, column]);
}
}