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

pg-cursor

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-cursor

Query cursor extension for node-postgres

  • 2.12.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
534K
increased by1.42%
Maintainers
1
Weekly downloads
 
Created

What is pg-cursor?

The pg-cursor npm package provides a way to handle large result sets in PostgreSQL by using server-side cursors. This allows you to fetch rows in smaller chunks, which can be more efficient and less memory-intensive than fetching all rows at once.

What are pg-cursor's main functionalities?

Creating a Cursor

This feature allows you to create a cursor for a given SQL query. The cursor can then be used to fetch rows in smaller chunks.

const { Client } = require('pg');
const Cursor = require('pg-cursor');

const client = new Client();
await client.connect();

const cursor = client.query(new Cursor('SELECT * FROM large_table'));

Fetching Rows

This feature allows you to fetch a specified number of rows from the cursor. This can be done repeatedly to fetch all rows in manageable chunks.

cursor.read(100, (err, rows) => {
  if (err) throw err;
  console.log(rows);
});

Closing the Cursor

This feature allows you to close the cursor when you are done fetching rows. This is important for freeing up resources on the server.

cursor.close((err) => {
  if (err) throw err;
  client.end();
});

Other packages similar to pg-cursor

FAQs

Package last updated on 24 Oct 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