dupdate
Apply database updates to application based on semver file names.
Install
$ npm install --save dupdate
Usage
"use strict"; const path = ;const dupdate = ; const history = '0.0.1-updates';const updated = ; const updater = path: path history updated; updater;
API
new dupdate.Updater(options)
or dupdate(options)
create a Updater instance.
options
- path:
string
- path to contain updates scripts. Defaults to./updates
- exitOnFailure:
boolean
- exit current process if failure. Defaults totrue
- silent:
boolean
- do not show message for executing. Defaults tofaslse
- context:
object
- the context object for passing to update script. Defaults to{}
- isUpdated:
function(file: string, [callback]) => [Promise]
- the function to check the update found whether has been applied. - afterUpdate:
function(context: object, update: function, [callback]) => [Promise]
the callback for one update script has been applied.
Updater.prototype.apply(callback) => [Promise]
Apply updates with callback function or return a Promise.
The result returned in callback(err, result)
or for .then(result => ...)
is an Object:
result
- context:
object
- the context from constructor - updates:
number
- the updated count - skips:
number
- the skipped count
Credits
- Yuan Tao
- Dom Harrington
- KeystoneJS - for the concept
License
MIT © Yuan Tao