Skip to content

Instantly share code, notes, and snippets.

@ryankelley
Created September 29, 2013 04:23
Show Gist options
  • Save ryankelley/6749323 to your computer and use it in GitHub Desktop.
Save ryankelley/6749323 to your computer and use it in GitHub Desktop.
var GearController = {
'list': function (req, res) {
var filter = req.param('filter');
var query = 'SELECT gear.*, categories.name as CategoryName from gear join categories on categories.id = gear.CategoryId';
if (filter) {
var dbfilter = '%' + filter + '%';
Gear.query(query + ' WHERE gear.name LIKE ?', [dbfilter], function (err, data) {
if (err) return res.send(err, 500);
res.json(data);
});
} else {
Gear.query(query + ' LIMIT ?', [100], function (err, data) {
if (err) return res.send(err, 500);
res.json(data);
});
}
}
}
module.exports = GearController;
error: TypeError: Cannot read property 'config' of undefined
at module.exports.adapter.query (C:\code\packlightly\node_modules\sails-mysql\lib\adapter.js:54:29)
at self.(anonymous function) [as query] (C:\code\packlightly\node_modules\sails\node_modules\waterline\lib\waterline\query\adapters.js:22:20)
at GearController.list (C:\code\packlightly\api\controllers\GearController.js:17:18)
at _bind.enhancedFn (C:\code\packlightly\node_modules\sails\lib\router\bind.js:327:4)
at callbacks (C:\code\packlightly\node_modules\sails\node_modules\express\lib\router\index.js:161:37)
at param (C:\code\packlightly\node_modules\sails\node_modules\express\lib\router\index.js:135:11)
at param (C:\code\packlightly\node_modules\sails\node_modules\express\lib\router\index.js:132:11)
at pass (C:\code\packlightly\node_modules\sails\node_modules\express\lib\router\index.js:142:5)
at nextRoute (C:\code\packlightly\node_modules\sails\node_modules\express\lib\router\index.js:100:7)
at callbacks (C:\code\packlightly\node_modules\sails\node_modules\express\lib\router\index.js:164:11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment