This is a supporter for getblackboard.com; mainly for static API services. Let's see if this evolves into something else or not.
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.

39 lines
818 B

/**
* NationalityController
*
* @description :: Server-side logic for managing nationalities
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
search: function(req, res) {
var word = req.param('query'),
query = Nationality.find();
if (word != undefined)
query = Nationality.find({
where: {
or: [
{english: {contains: word}},
{thai: {contains: word}},
]
},
sort: {
thai: 1,
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);
}
});
}
};