You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
784 B
38 lines
784 B
/** |
|
* 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'), |
|
query = Flag.find(); |
|
|
|
if (word != undefined) |
|
query = Flag.find({ |
|
where: { |
|
or: [ |
|
{english: {contains: word}}, |
|
{iso2: word}, |
|
{iso3: word}, |
|
] |
|
}, |
|
sort: { |
|
english: 1 |
|
} |
|
}); |
|
|
|
page = ((req.query.page != undefined) ? +req.query.page : 1); |
|
query.paginate({page: page, limit: 10}).exec(function(err, items) { |
|
if (err) { |
|
res.send(400); |
|
} else { |
|
res.send(items); |
|
} |
|
}); |
|
} |
|
|
|
};
|
|
|