Socket
Socket
Sign inDemoInstall

postgres-array

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

postgres-array

Parse postgres array columns


Version published
Maintainers
1
Weekly downloads
6,024,041
decreased by-9.2%

Weekly downloads

Package description

What is postgres-array?

The postgres-array package is a utility for parsing and serializing arrays in the format used by PostgreSQL. It allows Node.js applications to easily convert between JavaScript arrays and the string format used by PostgreSQL for array columns.

What are postgres-array's main functionalities?

Parsing PostgreSQL array strings to JavaScript arrays

This feature allows you to convert a PostgreSQL array string into a JavaScript array. It is useful when you fetch data from a PostgreSQL database and want to work with it in JavaScript.

const parse = require('postgres-array').parse;
let postgresArray = '{1,2,3,4}';
let jsArray = parse(postgresArray);
// jsArray is now [1, 2, 3, 4]

Serializing JavaScript arrays to PostgreSQL array strings

This feature allows you to convert a JavaScript array into a PostgreSQL array string. It is useful when you need to insert or update data in a PostgreSQL database that requires the array format.

const stringify = require('postgres-array').stringify;
let jsArray = [1, 2, 3, 4];
let postgresArray = stringify(jsArray);
// postgresArray is now '{1,2,3,4}'

Other packages similar to postgres-array

Readme

Source

postgres-array tests

Parse postgres array columns

Install

npm install --save postgres-array

Usage

const { parse } = require('postgres-array')

parse('{1,2,3}', (value) => parseInt(value, 10))
//=> [1, 2, 3]

API

parse(input, [transform]) -> array
input

Required
Type: string

A Postgres array string.

transform

Type: function
Default: identity

A function that transforms non-null values inserted into the array.

License

MIT © Ben Drucker

Keywords

FAQs

Last updated on 08 Feb 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc