JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 315
  • Score
    100M100P100Q85713F
  • License BSD-3-Clause

Custom data types for node-postgres

Package Exports

  • pg-custom-types

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pg-custom-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pg-custom-types Build Status

Use custom data types with node-postgres.

Installation

npm install pg-custom-types

Documentation

types(pg, connection, types, callback)

Fetches the OIDs for the given types.

Parameters

parameter type description
pg Object The pg object from require('pg')
connection String The connection string to use when fetching the types
types Array The array of data type names to fetch
callback Function The callback to call after the types are fetched

Callback is calleed with an object containing a lookup table.

{ 21842552: 'geometry',
  21842762: 'geography' }

Example

var types = require('pg-custom-types');

types(pg, connection, ['geometry', 'geography'], (err, oids) {
  if (err) {
    throw err;
  }

  console.log(oids.geometry);
  console.log(oids.geography);

  pg.setTypeParser(oids.geometry, function (value) {
    // parse geometry type
  });
});