diff --git a/lib/waterline.js b/lib/waterline.js index 2fc426c2d..5875c7c84 100644 --- a/lib/waterline.js +++ b/lib/waterline.js @@ -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) {