How to use the rest-hapi.getAll function in rest-hapi

To help you get started, we’ve selected a few rest-hapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JKHeadley / appy-backend / server / api / user.js View on Github external
const getUserConnectionStatsHandler = function (request, reply) {
        const promises = []

        promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isFollowed: true, $count: true }, Log))
        promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isFollowing: true, $count: true }, Log))
        promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isContact: true, $count: true }, Log))

        return Q.all(promises)
          .then(function (result) {
            const connectionStats = {
              followers: result[0],
              following: result[1],
              contacts: result[2]
            }

            return reply(connectionStats);
          })
          .catch(function (error) {
            Log.error(error);
            return reply(RestHapi.errorHelper.formatResponse(error));
          });
github JKHeadley / appy-backend / backend / server / api / user.js View on Github external
const getUserConnectionStatsHandler = function (request, reply) {
        const promises = []

        promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isFollowed: true, $count: true }, Log))
        promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isFollowing: true, $count: true }, Log))
        promises.push(RestHapi.getAll(User, request.params._id, Connection, 'connections', { isContact: true, $count: true }, Log))

        return Q.all(promises)
          .then(function (result) {
            const connectionStats = {
              followers: result[0],
              following: result[1],
              contacts: result[2]
            }

            return reply(connectionStats);
          })
          .catch(function (error) {
            Log.error(error);
            return reply(RestHapi.errorHelper.formatResponse(error));
github JKHeadley / appy-backend / server / api / user.api.js View on Github external
const getUserConnectionStatsHandler = async function(request, h) {
      try {
        const promises = []

        promises.push(
          RestHapi.getAll(
            User,
            request.params._id,
            Connection,
            'connections',
            { isFollowed: true, $count: true },
            Log
          )
        )
        promises.push(
          RestHapi.getAll(
            User,
            request.params._id,
            Connection,
            'connections',
            { isFollowing: true, $count: true },
            Log