1 line
7.5 KiB
JSON
1 line
7.5 KiB
JSON
|
{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Stream = void 0;\nconst batch_js_1 = require(\"./batch.js\");\nconst describe_js_1 = require(\"./describe.js\");\nconst result_js_1 = require(\"./result.js\");\nconst sql_js_1 = require(\"./sql.js\");\nconst stmt_js_1 = require(\"./stmt.js\");\n/** A stream for executing SQL statements (a \"database connection\"). */\nclass Stream {\n /** @private */\n constructor(intMode) {\n this.intMode = intMode;\n }\n /** Execute a statement and return rows. */\n query(stmt) {\n return this.#execute(stmt, true, result_js_1.rowsResultFromProto);\n }\n /** Execute a statement and return at most a single row. */\n queryRow(stmt) {\n return this.#execute(stmt, true, result_js_1.rowResultFromProto);\n }\n /** Execute a statement and return at most a single value. */\n queryValue(stmt) {\n return this.#execute(stmt, true, result_js_1.valueResultFromProto);\n }\n /** Execute a statement without returning rows. */\n run(stmt) {\n return this.#execute(stmt, false, result_js_1.stmtResultFromProto);\n }\n #execute(inStmt, wantRows, fromProto) {\n const stmt = (0, stmt_js_1.stmtToProto)(this._sqlOwner(), inStmt, wantRows);\n return this._execute(stmt).then(r => fromProto(r, this.intMode));\n }\n /** Return a builder for creating and executing a batch.\n *\n * If `useCursor` is true, the batch will be executed using a Hrana cursor, which will stream results from\n * the server to the client, which consumes less memory on the server. This requires protocol version 3 or\n * higher.\n */\n batch(useCursor = false) {\n return new batch_js_1.Batch(this, useCursor);\n }\n /** Parse and analyze a statement. This requires protocol version 2 or higher. */\n describe(inSql) {\n const protoSql = (0, sql_js_1.sqlToProto)(this._sqlOwner(), inSql);\n return this._describe(protoSql).then(describe_js_1.describeResultFromProto);\n }\n /** Execute a sequence of statements separated by semicolons. This requires protocol version 2 or higher.\n * */\n sequence(inSql) {\n const protoSql = (0, sql_js_1.sqlToProto)(this._sqlOwner(), inSql);\n return this._sequence(protoSql);\n }\n /** Representation of integers returned from the database. See {@link IntMode}.\n *\n * This value affects the results of all operations on this stream.\n */\n intMode;\n}\nexports.Stream = Stream;","map":{"version":3,"names":["Object","defineProperty","exports","value","Stream","batch_js_1","require","describe_js_1","result_js_1","sql_js_1","stmt_js_1","constructor","intMode","query","stmt","execute","rowsResultFromProto","queryRow","rowResultFromProto","queryValue","valueResultFromProto","run","stmtResultFromProto","#execute","inStmt","wantRows","fromProto","stmtToProto","_sqlOwner","_execute","then","r","batch","useCursor","Batch","describe","inSql","protoSql","sqlToProto","_describe","describeResultFromProto","sequence","_sequence"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-cjs/stream.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Stream = void 0;\nconst batch_js_1 = require(\"./batch.js\");\nconst describe_js_1 = require(\"./describe.js\");\nconst result_js_1 = require(\"./result.js\");\nconst sql_js_1 = require(\"./sql.js\");\nconst stmt_js_1 = require(\"./stmt.js\");\n/** A stream for executing SQL statements (a \"database connection\"). */\nclass Stream {\n /** @private */\n constructor(intMode) {\n this.intMode = intMode;\n }\n /** Execute a statement and return rows. */\n query(stmt) {\n return this.#execute(stmt, true, result_js_1.rowsResultFromProto);\n }\n /** Execute a statement and return at most a single row. */\n queryRow(stmt) {\n return this.#execute(stmt, true, result_js_1.rowResultFromProto);\n }\n /** Execute a statement and return at most a single value. */\n queryValue(stmt) {\n return this.#execute(stmt
|