]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/utils.js
Server: remove useless hash affectations
[github/Chocobozzz/PeerTube.git] / server / models / utils.js
CommitLineData
5c39adb7
C
1'use strict'
2
3const parallel = require('async/parallel')
4
5const utils = {
c4403b29 6 listForApiWithCount
5c39adb7
C
7}
8
9function listForApiWithCount (query, start, count, sort, callback) {
10 const self = this
11
12 parallel([
13 function (asyncCallback) {
14 self.find(query).skip(start).limit(count).sort(sort).exec(asyncCallback)
15 },
16 function (asyncCallback) {
17 self.count(query, asyncCallback)
18 }
19 ], function (err, results) {
20 if (err) return callback(err)
21
22 const data = results[0]
23 const total = results[1]
24 return callback(null, data, total)
25 })
26}
27
28// ---------------------------------------------------------------------------
29
30module.exports = utils