|
|
|
@ -9,10 +9,10 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
search: function(req, res) { |
|
|
|
|
var word = req.param('query'), |
|
|
|
|
revisionQuery = ObjRevision.find(); |
|
|
|
|
query = ObjRevision.find(); |
|
|
|
|
|
|
|
|
|
if (word != undefined) |
|
|
|
|
revisionQuery = ObjRevision.find({ |
|
|
|
|
query = ObjRevision.find({ |
|
|
|
|
where: { |
|
|
|
|
or: [ |
|
|
|
|
{obj: {jarvisId: {contains: word}}}, |
|
|
|
@ -24,7 +24,8 @@ module.exports = {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
revisionQuery.limit(10).exec(function(err, items) { |
|
|
|
|
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 { |
|
|
|
@ -35,39 +36,51 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
jarvisid: function(req, res) { |
|
|
|
|
var word = req.param('query'), |
|
|
|
|
revisionQuery = ObjRevision.find(); |
|
|
|
|
_options = {}, |
|
|
|
|
_count, query; |
|
|
|
|
|
|
|
|
|
if (word != undefined) |
|
|
|
|
revisionQuery = ObjRevision.find({ |
|
|
|
|
jarvisId: word, |
|
|
|
|
sort: { date: 1} |
|
|
|
|
}); |
|
|
|
|
_options['jarvisId'] = word; |
|
|
|
|
_options['sort'] = {date: -1}; |
|
|
|
|
|
|
|
|
|
revisionQuery.limit(10).exec(function(err, items) { |
|
|
|
|
if (err) { |
|
|
|
|
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); |
|
|
|
|
} else { |
|
|
|
|
res.send(items); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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'), |
|
|
|
|
revisionQuery = ObjRevision.find(); |
|
|
|
|
_options = {}, |
|
|
|
|
_count, query; |
|
|
|
|
|
|
|
|
|
if (word != undefined) |
|
|
|
|
revisionQuery = ObjRevision.find({ |
|
|
|
|
bbApi: word, |
|
|
|
|
sort: { date: 1} |
|
|
|
|
}); |
|
|
|
|
_options['bbApi'] = word; |
|
|
|
|
_options['sort'] = {date: -1}; |
|
|
|
|
|
|
|
|
|
revisionQuery.limit(10).exec(function(err, items) { |
|
|
|
|
if (err) { |
|
|
|
|
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); |
|
|
|
|
} else { |
|
|
|
|
res.send(items); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
query.paginate({page: page, limit: 10}).exec(function(err, items) { |
|
|
|
|
if (err) { |
|
|
|
|
res.send(400); |
|
|
|
|
} else { |
|
|
|
|
res.send({count: total, results: items}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|