How to use the machinepack-postgresql.getConnection 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 / connection / spawn-connection.js View on Github external
module.exports = function spawnConnection(datastore, cb) {
  // Validate datastore
  if (!datastore || !datastore.manager || !datastore.config) {
    return cb(new Error('Spawn Connection requires a valid datastore.'));
  }

  PG.getConnection({
    manager: datastore.manager,
    meta: datastore.config
  })
  .switch({
    error: function error(err) {
      return cb(err);
    },
    failed: function failedToConnect(err) {
      // Setup some basic troubleshooting tips
      console.error('Troubleshooting tips:');
      console.error('');

      // Used below to indicate whether the error is potentially related to config
      // (in which case we'll display a generic message explaining how to configure all the things)
      var isPotentiallyConfigRelated;
      isPotentiallyConfigRelated = true;
github balderdashy / sails-postgresql / test / support / bootstrap.js View on Github external
Support.Seed = function seed(tableName, cb) {
  var manager = adapter.datastores[_.first(_.keys(adapter.datastores))].manager;
  PG.getConnection({
    manager: manager,
    meta: Support.Config
  }).exec(function getConnectionCb(err, report) {
    if (err) {
      return cb(err);
    }

    var query = [
      'INSERT INTO "' + tableName + '" ("fieldA", "fieldB", "fieldC", "fieldD") ',
      'values (\'foo\', \'bar\', null, null), (\'foo_2\', \'bAr_2\', $1, $2);'
    ].join('');

    PG.sendNativeQuery({
      connection: report.connection,
      nativeQuery: query,
      valuesToEscape: [new Buffer([1, 2, 3]), new Date('2001-06-15 12:00:00')]
github balderdashy / sails-postgresql / test / support / bootstrap.js View on Github external
Support.Teardown = function teardown(tableName, cb) {
  var manager = adapter.datastores[_.first(_.keys(adapter.datastores))].manager;
  PG.getConnection({
    manager: manager,
    meta: Support.Config
  }).exec(function getConnectionCb(err, report) {
    if (err) {
      return cb(err);
    }

    var query = 'DROP TABLE IF EXISTS \"' + tableName + '";';
    PG.sendNativeQuery({
      connection: report.connection,
      nativeQuery: query
    }).exec(function dropTableCb(err) {
      if (err) {
        return cb(err);
      }