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.
88 lines
2.0 KiB
88 lines
2.0 KiB
/** |
|
* ObjRevisionController |
|
* |
|
* @description :: Server-side logic for managing objrevisions |
|
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers |
|
*/ |
|
|
|
module.exports = { |
|
|
|
search: function(req, res) { |
|
var word = req.param('query'), |
|
query = ObjRevision.find(); |
|
|
|
if (word != undefined) |
|
query = ObjRevision.find({ |
|
where: { |
|
or: [ |
|
{obj: {jarvisId: {contains: word}}}, |
|
{obj: {bbApi: {contains: word}}} |
|
] |
|
}, |
|
sort: { |
|
date: 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); |
|
} |
|
}); |
|
}, |
|
|
|
jarvisid: function(req, res) { |
|
var word = req.param('query'), |
|
_options = {}, |
|
_count, query; |
|
|
|
if (word != undefined) |
|
_options['jarvisId'] = word; |
|
_options['sort'] = {date: -1}; |
|
|
|
query = ObjRevision.find(_options); |
|
page = ((req.query.page != undefined) ? +req.query.page : 1); |
|
ObjRevision.count(_options).exec(function(err, total) { |
|
if (err) |
|
res.send(400); |
|
|
|
query.paginate({page: page, limit: 10}).exec(function(err, items) { |
|
if (err) { |
|
res.send(400); |
|
} else { |
|
res.send({count: total, results: items}); |
|
} |
|
}); |
|
}); |
|
}, |
|
|
|
bbapi: function(req, res) { |
|
var word = req.param('query'), |
|
_options = {}, |
|
_count, query; |
|
|
|
if (word != undefined) |
|
_options['bbApi'] = word; |
|
_options['sort'] = {date: -1}; |
|
|
|
query = ObjRevision.find(_options); |
|
page = ((req.query.page != undefined) ? +req.query.page : 1); |
|
ObjRevision.count(_options).exec(function(err, total) { |
|
if (err) |
|
res.send(400); |
|
|
|
query.paginate({page: page, limit: 10}).exec(function(err, items) { |
|
if (err) { |
|
res.send(400); |
|
} else { |
|
res.send({count: total, results: items}); |
|
} |
|
}); |
|
}); |
|
} |
|
|
|
}; |
|
|
|
|