Skip to content

Instantly share code, notes, and snippets.

@zrobit
Created January 17, 2017 08:56
Show Gist options
  • Select an option

  • Save zrobit/f264de48012b84e628dac0c5500d4468 to your computer and use it in GitHub Desktop.

Select an option

Save zrobit/f264de48012b84e628dac0c5500d4468 to your computer and use it in GitHub Desktop.
waterline orm load on express app server startup
var config = {
dir: './models',
adapters: {
'memory': require('sails-memory')
},
connections: {
default: {
adapter: 'memory'
}
}
};
var WaterlineLighter = require('waterline-lighter')
WaterlineLighter(config)
.then(function(waterline) {
/*
waterline.orm // waterline instance created by `new Waterline()`
waterline.config // config passed to orm.initialize (with some extra opts)
waterline.collections // collections loaded on the orm after inited
waterline.connections // connections used by the orm after inited
// The module also loads the connections and collections into the global object
global.collections // same as waterline.collections
global.connections // same as waterline.connections
*/
})
.then(function() {
require('./app.js')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment