How to use the pg-cursor function in pg-cursor

To help you get started, we’ve selected a few pg-cursor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FreeFeed / freefeed-server / app / export / gdpr.js View on Github external
}

    process.stdout.write('\n');

    const downloadUrls = [];
    process.stdout.write(`- getting user's attachments: `);

    {
      const attachmentTypes = {
        'audio':   'AudioObject',
        'general': 'DataDownload',
        'image':   'ImageObject',
      };

      const sql = `SELECT * FROM "attachments" WHERE "user_id" = $1`;  // using '$1' instead of '?' as we're VERY close to postgres in this call
      const cursor = pg.query(new PgCursor(sql, [user.id]));
      const read = promisify(cursor.read).bind(cursor);

      while (true) {  // eslint-disable-line no-constant-condition
        const rows = await read(100);

        if (rows.length === 0) {
          cursor.close(noop);
          break;
        }

        process.stdout.write('.');

        for (const attachmentRow of rows) {
          if (attachmentRow.media_type === null) {
            // skip bogus attachments
            continue;
github gajus / slonik / src / QueryStream.js View on Github external
constructor (text, values, options) {
    super({
      objectMode: true,
      ...options,
    });
    this.cursor = new Cursor(text, values);
    this._reading = false;
    this._closed = false;
    this.batchSize = (options || {}).batchSize || 100;

    // delegate Submittable callbacks to cursor
    this.handleRowDescription = this.cursor.handleRowDescription.bind(this.cursor);
    this.handleDataRow = this.cursor.handleDataRow.bind(this.cursor);
    this.handlePortalSuspended = this.cursor.handlePortalSuspended.bind(this.cursor);
    this.handleCommandComplete = this.cursor.handleCommandComplete.bind(this.cursor);
    this.handleReadyForQuery = this.cursor.handleReadyForQuery.bind(this.cursor);
    this.handleError = this.cursor.handleError.bind(this.cursor);
  }

pg-cursor

Query cursor extension for node-postgres

MIT
Latest version published 1 month ago

Package Health Score

88 / 100
Full package analysis

Popular pg-cursor functions