Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions lib/waterline.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,27 @@ Waterline.prototype.initialize = function(options, cb) {
var self = this;

// Ensure a config object is passed in containing adapters
if (!options) throw new Error('Usage Error: function(options, callback)');
if (!options.adapters) throw new Error('Options object must contain an adapters object');
if (!options.connections) throw new Error('Options object must contain a connections object');
if (!options) { throw new Error('Usage Error: function(options, callback)'); }
if (!options.adapters) { throw new Error('Options object must contain an adapters object'); }
if (!options.connections) { throw new Error('Options object must contain a connections object'); }

// Check that the given adapter is compatible with Waterline 0.11.x.
try {
_.each(options.adapters, function(adapter) {
// Adapters meant for Waterline >= 0.12 will have an adapterApiVersion property, so if we
// see that then we know the adapter won't work with this version of Waterline.
if (!_.isUndefined(adapter.adapterApiVersion)) {
throw new Error(
'\n-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-\n'+
'Cannot initialize Waterline.\n'+
'The installed version of adapter `' + adapter.identity + '` is too new!\n' +
'Please try installing a version < 1.0.\n' +
'-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-\n');
}
});
} catch (e) {
return cb(e);
}

// Allow collections to be passed in to the initialize method
if (options.collections) {
Expand Down