Export knex.raw('CURRENT_TIMESTAMP') for quick usage
See original GitHub issueMaybe knex should allow people to write like this:
table.dateTime('updated_at')
.defaultTo(knex.CURRENT_TIMESTAMP)
table.date('day')
.defaultTo(knex.CURRENT_DATE)
table.dateTime('timestamp')
.defaultTo(Date.now)
Issue Analytics
- State:
- Created 10 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to set `updatedAt` timestamp in Knex.js properly?
raw ('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));. But it doesn't work either. How do I make it work? Please help. javascript ...
Read more >Knex.js: SQL Query Builder for Javascript
Knex.js is a "batteries included" SQL query builder for PostgreSQL, CockroachDB, MSSQL, MySQL, MariaDB, SQLite3, Better-SQLite3, Oracle, and Amazon Redshift ...
Read more >Knex ❤️ PSQL: updating timestamps like a pro
How to use PSQL trigger functions in Knex.js to keep updated_at in ... the current timestamp when true is passed as the second...
Read more >egg-knex - npm
If you want to call literals or functions in mysql , you can use raw . Inner Literal. CURRENT_TIMESTAMP(): The database system current...
Read more >Generated GraphQL: Part 1 - Brandon Konkle
raw('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";') // timestamp updates await knex.raw(` CREATE OR REPLACE FUNCTION set_updated_at() RETURNS ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For people ending up here from Google. This is the way how to do it in 2017:
This seems to have been implemented by #372.
Might be nice to have some better documentation for this, though.