How to use pg-types - 10 common examples

To help you get started, we’ve selected a few pg-types 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 DefinitelyTyped / DefinitelyTyped / pg-types / pg-types-tests.ts View on Github external
/// 
import * as types from "pg-types";

types.getTypeParser(1184, 'text');

types.setTypeParser(1184, (value) => value === null ? null : value);
types.setTypeParser(1186, 'text', (value) => value === null ? null : value);
types.setTypeParser(1186, 'binary', (value) => value.toISOString());
types.setTypeParser(1185, (value) => types.arrayParser.create(value, (x) => x).parse());

var TIMESTAMPTZ_OID = 1184
var TIMESTAMP_OID = 1114
var parseFn = function(val: any) {
   return val === null ? null : moment(val)
}
types.setTypeParser(TIMESTAMPTZ_OID, parseFn)
types.setTypeParser(TIMESTAMP_OID, parseFn)
github DefinitelyTyped / DefinitelyTyped / pg-types / pg-types-tests.ts View on Github external
/// 
/// 
import * as types from "pg-types";

types.getTypeParser(1184, 'text');

types.setTypeParser(1184, (value) => value === null ? null : value);
types.setTypeParser(1186, 'text', (value) => value === null ? null : value);
types.setTypeParser(1186, 'binary', (value) => value.toISOString());
types.setTypeParser(1185, (value) => types.arrayParser.create(value, (x) => x).parse());

var TIMESTAMPTZ_OID = 1184
var TIMESTAMP_OID = 1114
var parseFn = function(val: any) {
   return val === null ? null : moment(val)
}
types.setTypeParser(TIMESTAMPTZ_OID, parseFn)
types.setTypeParser(TIMESTAMP_OID, parseFn)
github DefinitelyTyped / DefinitelyTyped / pg-types / pg-types-tests.ts View on Github external
/// 
/// 
import * as types from "pg-types";

types.getTypeParser(1184, 'text');

types.setTypeParser(1184, (value) => value === null ? null : value);
types.setTypeParser(1186, 'text', (value) => value === null ? null : value);
types.setTypeParser(1186, 'binary', (value) => value.toISOString());
types.setTypeParser(1185, (value) => types.arrayParser.create(value, (x) => x).parse());

var TIMESTAMPTZ_OID = 1184
var TIMESTAMP_OID = 1114
var parseFn = function(val: any) {
   return val === null ? null : moment(val)
}
types.setTypeParser(TIMESTAMPTZ_OID, parseFn)
types.setTypeParser(TIMESTAMP_OID, parseFn)
github DefinitelyTyped / DefinitelyTyped / pg-types / pg-types-tests.ts View on Github external
/// 
/// 
import * as types from "pg-types";

types.getTypeParser(1184, 'text');

types.setTypeParser(1184, (value) => value === null ? null : value);
types.setTypeParser(1186, 'text', (value) => value === null ? null : value);
types.setTypeParser(1186, 'binary', (value) => value.toISOString());
types.setTypeParser(1185, (value) => types.arrayParser.create(value, (x) => x).parse());

var TIMESTAMPTZ_OID = 1184
var TIMESTAMP_OID = 1114
var parseFn = function(val: any) {
   return val === null ? null : moment(val)
}
types.setTypeParser(TIMESTAMPTZ_OID, parseFn)
types.setTypeParser(TIMESTAMP_OID, parseFn)
github brianc / node-postgres / packages / pg / lib / defaults.js View on Github external
statement_timeout: false,

  // max milliseconds to wait for query to complete (client side)
  query_timeout: false,

  connect_timeout: 0,

  keepalives: 1,

  keepalives_idle: 0
}

var pgTypes = require('pg-types')
// save default parsers
var parseBigInteger = pgTypes.getTypeParser(20, 'text')
var parseBigIntegerArray = pgTypes.getTypeParser(1016, 'text')

// parse int8 so you can get your count values as actual numbers
module.exports.__defineSetter__('parseInt8', function (val) {
  pgTypes.setTypeParser(20, 'text', val ? pgTypes.getTypeParser(23, 'text') : parseBigInteger)
  pgTypes.setTypeParser(1016, 'text', val ? pgTypes.getTypeParser(1007, 'text') : parseBigIntegerArray)
})
github brianc / node-postgres / packages / pg / lib / defaults.js View on Github external
// false=unlimited
  statement_timeout: false,

  // max milliseconds to wait for query to complete (client side)
  query_timeout: false,

  connect_timeout: 0,

  keepalives: 1,

  keepalives_idle: 0
}

var pgTypes = require('pg-types')
// save default parsers
var parseBigInteger = pgTypes.getTypeParser(20, 'text')
var parseBigIntegerArray = pgTypes.getTypeParser(1016, 'text')

// parse int8 so you can get your count values as actual numbers
module.exports.__defineSetter__('parseInt8', function (val) {
  pgTypes.setTypeParser(20, 'text', val ? pgTypes.getTypeParser(23, 'text') : parseBigInteger)
  pgTypes.setTypeParser(1016, 'text', val ? pgTypes.getTypeParser(1007, 'text') : parseBigIntegerArray)
})
github DefinitelyTyped / DefinitelyTyped / types / pg-types / pg-types-tests.ts View on Github external
import * as types from "pg-types";

types.getTypeParser(1184, 'text');

types.setTypeParser(1184, (value) => value === null ? null : value);
types.setTypeParser(1186, 'text', (value) => value === null ? null : value);
types.setTypeParser(1186, 'binary', (value) => value.toISOString());
types.setTypeParser(1185, (value) => types.arrayParser.create(value, (x) => x).parse());

const TIMESTAMPTZ_OID = 1184;
const TIMESTAMP_OID = 1114;
types.setTypeParser(TIMESTAMPTZ_OID, parseInt);
types.setTypeParser(TIMESTAMP_OID, parseInt);
github DefinitelyTyped / DefinitelyTyped / pg-types / pg-types-tests.ts View on Github external
import * as types from "pg-types";

types.getTypeParser(1184, 'text');

types.setTypeParser(1184, (value) => value === null ? null : value);
types.setTypeParser(1186, 'text', (value) => value === null ? null : value);
types.setTypeParser(1186, 'binary', (value) => value.toISOString());
types.setTypeParser(1185, (value) => types.arrayParser.create(value, (x) => x).parse());

var TIMESTAMPTZ_OID = 1184
var TIMESTAMP_OID = 1114
var parseFn = function(val: any) {
   return val === null ? null : moment(val)
}
types.setTypeParser(TIMESTAMPTZ_OID, parseFn)
types.setTypeParser(TIMESTAMP_OID, parseFn)
github brianc / node-postgres / test / integration / client / huge-numeric-tests.js View on Github external
helper.pg.connect(helper.config, assert.success(function(client, done) {
  var types = require('pg-types');
  //1231 = numericOID
  types.setTypeParser(1700, function(){
    return 'yes';
  })
  types.setTypeParser(1700, 'binary', function(){
    return 'yes';
  })
  var bignum = '294733346389144765940638005275322203805';
  client.query('CREATE TEMP TABLE bignumz(id numeric)');
  client.query('INSERT INTO bignumz(id) VALUES ($1)', [bignum]);
  client.query('SELECT * FROM bignumz', assert.success(function(result) {
    assert.equal(result.rows[0].id, 'yes')
    helper.pg.end();
    done();
  }))
}));
github DefinitelyTyped / DefinitelyTyped / types / pg-types / pg-types-tests.ts View on Github external
import * as types from "pg-types";

types.getTypeParser(1184, 'text');

types.setTypeParser(1184, (value) => value === null ? null : value);
types.setTypeParser(1186, 'text', (value) => value === null ? null : value);
types.setTypeParser(1186, 'binary', (value) => value.toISOString());
types.setTypeParser(1185, (value) => types.arrayParser.create(value, (x) => x).parse());

const TIMESTAMPTZ_OID = 1184;
const TIMESTAMP_OID = 1114;
types.setTypeParser(TIMESTAMPTZ_OID, parseInt);
types.setTypeParser(TIMESTAMP_OID, parseInt);

pg-types

Query result type converters for node-postgres

MIT
Latest version published 10 months ago

Package Health Score

83 / 100
Full package analysis