pg-range version 1.1.2 is a plugin for node-postgres that adds automatic parsing and serialization of PostgreSQL range types (int4range, int8range, numrange, tsrange, tstzrange, daterange). It integrates with the pg library via install method and provides a Range class extending stRange.js for operations like contains, intersects. Released under MIT, last updated in 2016, stable but unmaintained. Differentiator: seamless integration with pg, no need for manual type handlers.
npm install pg-rangeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows installation, querying a range column, and inserting a range value using pg-range with node-postgres.
Always use the Range constructor from pg-range itself, e.g., new Range(1, 3).
Call require('pg-range').install(pg) on the pg module you use.Consider migrating to pg-types or custom type parsers if issues arise with newer pg versions.
Check bounds using string comparison for characters: '[]', '[)', '(]', '()'.
Use const { install } = require('pg-range'); or const install = require('pg-range').install;Use const { Range } = require('pg-range'); and call new Range(...).Run npm install pg-range and ensure CommonJS environment (e.g., use require, not import).
Downgrade pg to version 7 or implement a custom type parser.