1 line
6.7 KiB
JSON
1 line
6.7 KiB
JSON
|
{"ast":null,"code":"import { Batch } from \"./batch.js\";\nimport { describeResultFromProto } from \"./describe.js\";\nimport { stmtResultFromProto, rowsResultFromProto, rowResultFromProto, valueResultFromProto } from \"./result.js\";\nimport { sqlToProto } from \"./sql.js\";\nimport { stmtToProto } from \"./stmt.js\";\n/** A stream for executing SQL statements (a \"database connection\"). */\nexport class 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, rowsResultFromProto);\n }\n /** Execute a statement and return at most a single row. */\n queryRow(stmt) {\n return this.#execute(stmt, true, rowResultFromProto);\n }\n /** Execute a statement and return at most a single value. */\n queryValue(stmt) {\n return this.#execute(stmt, true, valueResultFromProto);\n }\n /** Execute a statement without returning rows. */\n run(stmt) {\n return this.#execute(stmt, false, stmtResultFromProto);\n }\n #execute(inStmt, wantRows, fromProto) {\n const stmt = 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(this, useCursor);\n }\n /** Parse and analyze a statement. This requires protocol version 2 or higher. */\n describe(inSql) {\n const protoSql = sqlToProto(this._sqlOwner(), inSql);\n return this._describe(protoSql).then(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 = 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}","map":{"version":3,"names":["Batch","describeResultFromProto","stmtResultFromProto","rowsResultFromProto","rowResultFromProto","valueResultFromProto","sqlToProto","stmtToProto","Stream","constructor","intMode","query","stmt","execute","queryRow","queryValue","run","#execute","inStmt","wantRows","fromProto","_sqlOwner","_execute","then","r","batch","useCursor","describe","inSql","protoSql","_describe","sequence","_sequence"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/stream.js"],"sourcesContent":["import { Batch } from \"./batch.js\";\nimport { describeResultFromProto } from \"./describe.js\";\nimport { stmtResultFromProto, rowsResultFromProto, rowResultFromProto, valueResultFromProto, } from \"./result.js\";\nimport { sqlToProto } from \"./sql.js\";\nimport { stmtToProto } from \"./stmt.js\";\n/** A stream for executing SQL statements (a \"database connection\"). */\nexport class 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, rowsResultFromProto);\n }\n /** Execute a statement and return at most a single row. */\n queryRow(stmt) {\n return this.#execute(stmt, true, rowResultFromProto);\n }\n /** Execute a statement and return at most a single value. */\n queryValue(stmt) {\n return this.#execute(stmt, true, valueResultFromProto);\n }\n /** Execute a statement without returning rows. */\n run(stmt) {\n return this.#execute(stmt, false, stmtResultFromProto);\n }\n #execute(inStmt, wantRows, fromProto) {\n const stmt = stmtToProto(this._sqlOwner(), inStmt, wantRows);\n return this._execute(stmt).then((r) =
|