Members
db
- Source:
The application's database.
Methods
autoRun()
- Source:
Runs this script, performing the following actions:
- Open a connection to the database.
- Execute the
run
method. - Execute the
onSuccess
oronFailure
callback depending on whether therun
method was successful (throwing an error or returning a rejected promise will be considered a failure). - Close the connection to the database.
- Exit the process with code 0 if the script was successful or 1 otherwise.
If the $NO_SCRIPT
environment variable is set, do not do anything. This
allows this script to be reused by importing it and calling its run
method manually, with the setup/teardown steps being handled by the parent
script.
exit()
- Source:
Called when the script is done executing (successfully or not) and after closing the connection to the database.
It exits the process with code 0, or with the value of the exitCode
property (which is set to 1 by onFailure
).
onFailure()
- Source:
Called if the script fails.
It logs a FATAL message to the console by default and sets the exit code of
the script to 1 for when the exit
method is called.
onSuccess()
- Source:
Called if the script succeeds.
It logs an INFO message to the console by default.
run()
- Source:
Runs the script.
This method should be overriden by subclasses to do the actual work.