Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Can't use built-in functions on UPDATE #46

Closed
mikecleach opened this issue Dec 11, 2013 · 1 comment
Closed

Can't use built-in functions on UPDATE #46

mikecleach opened this issue Dec 11, 2013 · 1 comment

Comments

@mikecleach
Copy link

Is there no way to use built-in functions of my database in an update?

For example, I need to set a field to the current time. I can't use something like a formatted moment.js date representing right now because the time periods are short enough that any difference between my computer's time and the database server's time creates unstable timings.

What I need is to be able to do

.update().table('tablename').set('last_check', 'NOW()') and not have the resulting SQL built:
UPDATE tablename SET last_check = 'NOW()' WHERE (id = 2)

because the NOW() function does not run; it is evaluated as a string. Is there some way to do this? If not, I think it should be possible somehow.

@mikecleach
Copy link
Author

It appears that the option usingValuePlaceholders set to true enables what I was trying to do. I recommend adding an example of this option to the docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant