Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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;
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);
}
module.exports = function (module) {
var helpers = require('./helpers');
const util = require('util');
var Cursor = require('pg-cursor');
Cursor.prototype.readAsync = util.promisify(Cursor.prototype.read);
const sleep = util.promisify(setTimeout);
require('./sorted/add')(module);
require('./sorted/remove')(module);
require('./sorted/union')(module);
require('./sorted/intersect')(module);
module.getSortedSetRange = async function (key, start, stop) {
return await getSortedSetRange(key, start, stop, 1, false);
};
module.getSortedSetRevRange = async function (key, start, stop) {
return await getSortedSetRange(key, start, stop, -1, false);
};
module.getSortedSetRangeWithScores = async function (key, start, stop) {