kopia lustrzana https://github.com/manuelkasper/sotlas-api
Replace deprecated cursor.count syntax
rodzic
1e757e4667
commit
8d7bbb4986
|
@ -247,13 +247,14 @@ app.get('/activators/search', (req, res) => {
|
|||
if (req.query.q !== undefined && req.query.q !== '') {
|
||||
query = {callsign: {'$regex': req.query.q, '$options': 'i'}};
|
||||
}
|
||||
let cursor = db.getDb().collection('activators').find(query, {projection: {'_id': false}}).sort(sort);
|
||||
cursor.count((err, count) => {
|
||||
|
||||
db.getDb().collection('activators').countDocuments(query, (err, count) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
res.status(500).end();
|
||||
return;
|
||||
}
|
||||
let cursor = db.getDb().collection('activators').find(query, {projection: {'_id': false}}).sort(sort);
|
||||
|
||||
cursor.skip(skip).limit(limit).toArray((err, activators) => {
|
||||
res.json({activators, total: count});
|
||||
|
|
Ładowanie…
Reference in New Issue