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) => 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}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,YAAY;AAClC,SAASC,uBAAuB,QAAQ,eAAe;AACvD,SAASC,mBAAmB,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAEC,oBAAoB,QAAS,aAAa;AACjH,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,WAAW,QAAQ,WAAW;AACvC;AACA,OAAO,MAAMC,MAAM,CAAC;EAChB;EACAC,WAAWA,CAACC,OAAO,EAAE;IACjB,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EACA;EACAC,KAAKA,CAACC,IAAI,EAAE;IACR,OAAO,IAAI,CAAC,CAACC,OAAO,CAACD,IAAI,EAAE,IAAI,EAAET,mBAAmB,CAAC;EACzD;EACA;EACAW,QAAQA,CAACF,IAAI,EAAE;IACX,OAAO,IAAI,CAAC,CAACC,OAAO,CAACD,IAAI,EAAE,IAAI,EAAER,kBAAkB,CAAC;EACxD;EACA;EACAW,UAAUA,CAACH,IAAI,EAAE;IACb,OAAO,IAAI,CAAC,CAACC,OAAO,CAACD,IAAI,EAAE,IAAI,EAAEP,oBAAoB,CAAC;EAC1D;EACA;EACAW,GAAGA,CAACJ,IAAI,EAAE;IACN,OAAO,IAAI,CAAC,CAACC,OAAO,CAACD,IAAI,EAAE,KAAK,EAAEV,mBAAmB,CAAC;EAC1D;EACA,CAACW,OAAOI,CAACC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE;IAClC,MAAMR,IAAI,GAAGL,WAAW,CAAC,IAAI,CAACc,SAAS,CAAC,CAAC,EAAEH,MAAM,EAAEC,QAAQ,CAAC;IAC5D,OAAO,IAAI,CAACG,QAAQ,CAACV,IAAI,CAAC,CAACW,IAAI,CAAEC,CAAC,IAAKJ,SAAS,CAACI,CAAC,EAAE,IAAI,CAACd,OAAO,CAAC,CAAC;EACtE;EACA;AACJ;AACA;AACA;AACA;AACA;EACIe,KAAKA,CAACC,SAAS,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