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.
 
 
 
 

54 lines
1.2 KiB

/**
* TagController
*
* @description :: Server-side logic for managing Tags
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
list: function(req, res) {
var team = req.param('team'),
type = req.query.type,
format = req.query.format,
q = {
where: { team: team },
sort: { name: 1 }
};
if (type != undefined)
q['where'] = {
$and: [
{ team: team },
{ relatedTo: { $in: [type] } }
]
}
page = ((req.query.page != undefined) ? +req.query.page : 1);
Tag.find(q).paginate({page: page, limit: 10}).exec(function(err, items) {
if (format == 'long') {
res.send(items);
} else {
var tags = [];
for (var ind in items) {
tags.push(items[ind].name);
}
res.send(tags);
}
});
},
detail: function(req, res) {
var team = req.param('team'),
name = req.param('name');
Tag.findOne({team: team, name: name}).exec(function(err, item) {
if (item == undefined)
res.send({});
else
res.send(item);
});
}
};