mirror of
https://github.com/hanzoai/better-sqlite3.git
synced 2026-09-24 16:57:15 +00:00
21 lines
727 B
JavaScript
21 lines
727 B
JavaScript
'use strict';
|
|
exports.readonly = true; // Reading rows individually (`.get()`)
|
|
|
|
exports['better-sqlite3'] = (db, { table, columns, count }) => {
|
|
const stmt = db.prepare(`SELECT ${columns.join(', ')} FROM ${table} WHERE rowid = ?`);
|
|
let rowid = -1;
|
|
return () => stmt.get(++rowid % count + 1);
|
|
};
|
|
|
|
exports['node-sqlite3'] = async (db, { table, columns, count }) => {
|
|
const sql = `SELECT ${columns.join(', ')} FROM ${table} WHERE rowid = ?`;
|
|
let rowid = -1;
|
|
return () => db.get(sql, ++rowid % count + 1);
|
|
};
|
|
|
|
exports['node:sqlite'] = (db, { table, columns, count }) => {
|
|
const stmt = db.prepare(`SELECT ${columns.join(', ')} FROM ${table} WHERE rowid = ?`);
|
|
let rowid = -1;
|
|
return () => stmt.get(++rowid % count + 1);
|
|
};
|