Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function PgIterator (db, options) {
debug('# new PgIterator (db, options = %j)', options)
AbstractIterator.call(this, db)
this._keyAsBuffer = options.keyAsBuffer
this._valueAsBuffer = options.valueAsBuffer
const statement = PgIterator._parseOptions(db, options)
const relation = db._config._relation
const head = `
SELECT key::${db._keyColumnType}, value::${db._valueColumnType} FROM ${relation}
`
statement.clauses.unshift(head)
statement.text = statement.clauses.join(' ')
this._cursor = util.createCursor(db, statement)
}
function Iterator(db, options, cb) {
AbstractIterator.call(this, db);
this._db = db.knexDb;
options = options || {};
this._order = !options.reverse;
this._options = options;
names.forEach(function (i) {
goodOptions(options, i);
});
this._count = 0;
var self = this;
if ('limit' in options) {
this._limit = options.limit;
} else {
this._limit = -1;
}
if ('keyAsBuffer' in options) {
function PgIterator (db, options) {
AbstractIterator.call(this, db)
this._keyAsBuffer = options.keyAsBuffer
this._valueAsBuffer = options.valueAsBuffer
this._pool = db._pool
const params = this._params = []
const clauses = []
clauses.push(`SELECT key, value FROM ${db._qname}`)
const constraints = _constraintSql(options)
if (constraints) {
params.push(constraints)
clauses.push('WHERE $' + params.length)
}
clauses.push('ORDER BY key ' + (options.reverse ? 'DESC' : 'ASC'))