Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-types

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-types

Query result type converters for node-postgres

  • 4.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.4M
decreased by-14.57%
Maintainers
2
Weekly downloads
 
Created

What is pg-types?

The pg-types package is a collection of type parsers and formatters for use with the node-postgres family of packages. It allows for the customization of how database types are parsed into JavaScript types and vice versa, enhancing the flexibility and control over data serialization and deserialization processes when interacting with PostgreSQL databases.

What are pg-types's main functionalities?

Custom Type Parsing

This feature allows for the customization of how specific PostgreSQL types are parsed into JavaScript types. In the code sample, the setTypeParser method is used to parse PostgreSQL numeric types (type OID 1700) into JavaScript floats.

const { types } = require('pg');
types.setTypeParser(1700, (val) => parseFloat(val));

Array Parsing

Enables the parsing of PostgreSQL array types into JavaScript arrays. The code sample demonstrates how to parse an array of integers (type OID 1007) using a custom parsing function that utilizes the postgres-array package.

const { types } = require('pg');
const parseArray = require('postgres-array').parse;
types.setTypeParser(1007, (val) => parseArray(val, parseInt));

Other packages similar to pg-types

Keywords

FAQs

Package last updated on 22 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc