/** * FlagController * * @description :: Server-side logic for managing flags * @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers */ module.exports = { search: function(req, res) { var word = req.param('query'), flagQuery = Flag.find(); if (word != undefined) flagQuery = Flag.find({ where: { or: [ {english: {contains: word}}, {thai: {contains: word}}, {iso2: word}, ] }, sort: { thai: 1, english: 1 } }); flagQuery.limit(10).exec(function(err, flags) { if (err) { res.send(400); } else { res.send(flags); } }); } };