Files
dealplustech/dealplustech-astro/node_modules/@libsql/hrana-client/lib-cjs/stmt.js
Kunthawat Greethong 6402d885f9 Complete Astro migration - PDPA compliant website
- Migrated all pages from Next.js to Astro
- Added PDPA-compliant Privacy Policy (Thai)
- Added PDPA-compliant Terms & Conditions (Thai)
- Added Cookie Policy with disclosure (Thai)
- Implemented cookie consent banner (client-side)
- Integrated Umami Analytics placeholder
- Blog system with 3 posts
- Optimized Docker configuration for production
- Static site build (184KB, 11 pages)
- Ready for Easypanel deployment

Backup: /Users/kunthawatgreethong/Gitea/dealplustech-backup-nextjs-20260309.tar.gz
2026-03-09 18:28:01 +07:00

82 lines
2.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stmtToProto = exports.Stmt = void 0;
const sql_js_1 = require("./sql.js");
const value_js_1 = require("./value.js");
/** A statement that can be evaluated by the database. Besides the SQL text, it also contains the positional
* and named arguments. */
class Stmt {
/** The SQL statement text. */
sql;
/** @private */
_args;
/** @private */
_namedArgs;
/** Initialize the statement with given SQL text. */
constructor(sql) {
this.sql = sql;
this._args = [];
this._namedArgs = new Map();
}
/** Binds positional parameters from the given `values`. All previous positional bindings are cleared. */
bindIndexes(values) {
this._args.length = 0;
for (const value of values) {
this._args.push((0, value_js_1.valueToProto)(value));
}
return this;
}
/** Binds a parameter by a 1-based index. */
bindIndex(index, value) {
if (index !== (index | 0) || index <= 0) {
throw new RangeError("Index of a positional argument must be positive integer");
}
while (this._args.length < index) {
this._args.push(null);
}
this._args[index - 1] = (0, value_js_1.valueToProto)(value);
return this;
}
/** Binds a parameter by name. */
bindName(name, value) {
this._namedArgs.set(name, (0, value_js_1.valueToProto)(value));
return this;
}
/** Clears all bindings. */
unbindAll() {
this._args.length = 0;
this._namedArgs.clear();
return this;
}
}
exports.Stmt = Stmt;
function stmtToProto(sqlOwner, stmt, wantRows) {
let inSql;
let args = [];
let namedArgs = [];
if (stmt instanceof Stmt) {
inSql = stmt.sql;
args = stmt._args;
for (const [name, value] of stmt._namedArgs.entries()) {
namedArgs.push({ name, value });
}
}
else if (Array.isArray(stmt)) {
inSql = stmt[0];
if (Array.isArray(stmt[1])) {
args = stmt[1].map((arg) => (0, value_js_1.valueToProto)(arg));
}
else {
namedArgs = Object.entries(stmt[1]).map(([name, value]) => {
return { name, value: (0, value_js_1.valueToProto)(value) };
});
}
}
else {
inSql = stmt;
}
const { sql, sqlId } = (0, sql_js_1.sqlToProto)(sqlOwner, inSql);
return { sql, sqlId, args, namedArgs, wantRows };
}
exports.stmtToProto = stmtToProto;