(appId, collectionName, query, limit, skip)
| 484 | }, |
| 485 | |
| 486 | count(appId, collectionName, query, limit, skip) { |
| 487 | const deferred = q.defer(); |
| 488 | |
| 489 | try { |
| 490 | if (config.mongoDisconnected) { |
| 491 | deferred.reject('Database Not Connected'); |
| 492 | return deferred.promise; |
| 493 | } |
| 494 | |
| 495 | if (skip) { |
| 496 | skip = parseInt(skip, 10); |
| 497 | } |
| 498 | |
| 499 | const collection = config.mongoClient.db(appId).collection(mongoUtil.collection.getId(appId, collectionName)); |
| 500 | |
| 501 | // delete $include and $includeList recursively |
| 502 | query = _sanitizeQuery(query); |
| 503 | |
| 504 | let findQuery = collection.find(query); |
| 505 | if (skip) { |
| 506 | findQuery = findQuery.skip(skip); |
| 507 | } |
| 508 | |
| 509 | findQuery.count(query, (err, count) => { |
| 510 | if (err) { |
| 511 | winston.log('error', err); |
| 512 | deferred.reject(err); |
| 513 | } else { |
| 514 | deferred.resolve(count); |
| 515 | } |
| 516 | }); |
| 517 | } catch (err) { |
| 518 | winston.log('error', { |
| 519 | error: String(err), |
| 520 | stack: new Error().stack, |
| 521 | }); |
| 522 | deferred.reject(err); |
| 523 | } |
| 524 | return deferred.promise; |
| 525 | }, |
| 526 | |
| 527 | distinct(appId, collectionName, onKey, query, select, sort, limit, skip) { |
| 528 | const deferred = q.defer(); |
nothing calls this directly
no test coverage detected