Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
postgres-array
Advanced tools
Parse postgres array columns
Weekly downloads
Package description
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.
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}'
pg-promise is a PostgreSQL interface for Node.js. It includes robust support for parameterized queries, named parameters, and automatic conversion of JavaScript objects to PostgreSQL hstore format. It provides more comprehensive database interaction functionalities compared to postgres-array, which focuses solely on array conversion.
node-pg-types allows you to parse and serialize PostgreSQL types in Node.js. It is similar to postgres-array but supports a wider range of PostgreSQL types, not just arrays. It provides a more extensive solution for dealing with PostgreSQL data types in JavaScript.
Readme
Parse postgres array columns
npm install --save postgres-array
const { parse } = require('postgres-array')
parse('{1,2,3}', (value) => parseInt(value, 10))
//=> [1, 2, 3]
parse(input, [transform])
-> array
Required
Type: string
A Postgres array string.
Type: function
Default: identity
A function that transforms non-null values inserted into the array.
MIT © Ben Drucker
FAQs
Parse postgres array columns
The npm package postgres-array receives a total of 4,947,194 weekly downloads. As such, postgres-array popularity was classified as popular.
We found that postgres-array demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.