mirror of
https://github.com/knex/knex.git
synced 2025-07-04 23:50:32 +00:00
19 lines
462 B
JavaScript
19 lines
462 B
JavaScript
![]() |
// FunctionHelper
|
||
|
// -------
|
||
|
// Used for adding functions from the builder
|
||
|
// Example usage: table.dateTime('datetime_to_date').notNull().defaultTo(knex.fn.now());
|
||
|
class FunctionHelper {
|
||
|
constructor(client) {
|
||
|
this.client = client;
|
||
|
}
|
||
|
|
||
|
now(precision) {
|
||
|
if (typeof precision === 'number') {
|
||
|
return this.client.raw(`CURRENT_TIMESTAMP(${precision})`);
|
||
|
}
|
||
|
return this.client.raw('CURRENT_TIMESTAMP');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = FunctionHelper;
|