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

postgres-interval

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postgres-interval

Parse Postgres interval columns

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is postgres-interval?

The postgres-interval npm package is designed to parse and handle PostgreSQL interval types in JavaScript. It allows for the parsing of interval output from PostgreSQL into a JavaScript object, manipulation of these interval objects, and formatting of interval objects back into strings that PostgreSQL can understand. This is particularly useful when working with time-based data that needs to be manipulated or displayed in a JavaScript application.

What are postgres-interval's main functionalities?

Parsing PostgreSQL interval output

This feature allows for the parsing of a PostgreSQL interval string into a JavaScript object, making it easier to work with in a JavaScript codebase. The object contains properties for years, months, days, hours, minutes, and seconds.

const parseInterval = require('postgres-interval');
const result = parseInterval('1 year 2 months 3 days 04:05:06');
console.log(result);

Manipulating interval objects

After parsing an interval string into an object, this feature allows for the manipulation of the interval's properties (e.g., adding an extra day). The manipulated interval can then be converted back into a PostgreSQL interval string.

const parseInterval = require('postgres-interval');
const interval = parseInterval('1 day');
interval.days += 1;
console.log(interval.toPostgres());

Formatting intervals for PostgreSQL

This feature is useful for converting a manipulated interval object back into a string format that PostgreSQL can understand, enabling the updated interval to be used in database queries or operations.

const parseInterval = require('postgres-interval');
const interval = parseInterval('10 hours');
const formattedInterval = interval.toPostgres();
console.log(formattedInterval);

Other packages similar to postgres-interval

Keywords

FAQs

Package last updated on 12 Apr 2016

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