Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

ordermentum/async-iterator-pg-cursor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-iterator-pg-cursor

const Cursor = require('async-iterator-pg-cursor');
const pg = require('pg');

const host = process.env.DATABASE_HOST;
const user = process.env.DATABASE_USER;
const port = process.env.DATABASE_PORT;
const password = process.env.DATABASE_PASSWORD;
const database = process.env.DATABASE_NAME;
const client = new pg.Client({ database, host, port, user, password });

const query = `SELECT * FROM products`;

async function start() {
  await client.connect();
  const cursor = new Cursor(client, query);
  for await (const rows of cursor) {
    for (const row of rows) {
      console.log(row);
    }
  }

  return true;
};

start().then(() => process.exit());

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published