How to use the machinepack-postgresql.parseNativeQueryResult function in machinepack-postgresql

To help you get started, we’ve selected a few machinepack-postgresql 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 balderdashy / sails-postgresql / helpers / private / query / run-query.js View on Github external
success: function success(report) {
      //  ╔═╗╔═╗╦═╗╔═╗╔═╗  ┌─┐ ┬ ┬┌─┐┬─┐┬ ┬  ┬─┐┌─┐┌─┐┬ ┬┬ ┌┬┐┌─┐
      //  ╠═╝╠═╣╠╦╝╚═╗║╣   │─┼┐│ │├┤ ├┬┘└┬┘  ├┬┘├┤ └─┐│ ││  │ └─┐
      //  ╩  ╩ ╩╩╚═╚═╝╚═╝  └─┘└└─┘└─┘┴└─ ┴   ┴└─└─┘└─┘└─┘┴─┘┴ └─┘
      // If there was a query type given, parse the results.
      var queryResults = report.result;
      if (options.queryType) {
        try {
          queryResults = PG.parseNativeQueryResult({
            queryType: options.queryType,
            nativeQueryResult: report.result
          }).execSync();
        } catch (e) {
          return cb(e);
        }
      }

      return cb(null, queryResults);
    }
  });
github balderdashy / sails-postgresql / helpers / private / query / modify-record.js View on Github external
// If the query failed to run, release the connection and return the parsed
    // error footprint.
    if (err) {
      releaseConnection(options.connection, options.leased, function releaseCb() {
        return cb(err);
      });

      return;
    }

    // If the records were fetched, then pretend this was find and parse the
    // native query results.
    if (options.fetchRecords) {
      var parsedResults;
      try {
        parsedResults = PG.parseNativeQueryResult({
          queryType: 'select',
          nativeQueryResult: report
        }).execSync();
      } catch (e) {
        return cb(e);
      }

      return cb(undefined, parsedResults.result);
    }

    // Return the results
    return cb(undefined, report.result);
  });
};