/** * ObjReferenceController * * @description :: Server-side logic for managing objreferences * @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers */ module.exports = { search: function(req, res) { var word = req.param('query'), refQuery = ObjReference.find(); if (word != undefined) refQuery = ObjReference.find({ where: { or: [ {team: word}, {type: word}, {bbApi: word}, {id: word}, ] }, sort: { date: 1 } }); refQuery.limit(10).exec(function(err, items) { if (err) { res.send(400); } else { res.send(items); } }); } };