session.cjs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var session_exports = {};
  20. __export(session_exports, {
  21. PrismaSQLitePreparedQuery: () => PrismaSQLitePreparedQuery,
  22. PrismaSQLiteSession: () => PrismaSQLiteSession
  23. });
  24. module.exports = __toCommonJS(session_exports);
  25. var import_entity = require("../../entity.cjs");
  26. var import_logger = require("../../logger.cjs");
  27. var import_sql = require("../../sql/sql.cjs");
  28. var import_sqlite_core = require("../../sqlite-core/index.cjs");
  29. class PrismaSQLitePreparedQuery extends import_sqlite_core.SQLitePreparedQuery {
  30. constructor(prisma, query, logger, executeMethod) {
  31. super("async", executeMethod, query);
  32. this.prisma = prisma;
  33. this.logger = logger;
  34. }
  35. static [import_entity.entityKind] = "PrismaSQLitePreparedQuery";
  36. all(placeholderValues) {
  37. const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
  38. this.logger.logQuery(this.query.sql, params);
  39. return this.prisma.$queryRawUnsafe(this.query.sql, ...params);
  40. }
  41. async run(placeholderValues) {
  42. await this.all(placeholderValues);
  43. return [];
  44. }
  45. async get(placeholderValues) {
  46. const all = await this.all(placeholderValues);
  47. return all[0];
  48. }
  49. values(_placeholderValues) {
  50. throw new Error("Method not implemented.");
  51. }
  52. isResponseInArrayMode() {
  53. return false;
  54. }
  55. }
  56. class PrismaSQLiteSession extends import_sqlite_core.SQLiteSession {
  57. constructor(prisma, dialect, options) {
  58. super(dialect);
  59. this.prisma = prisma;
  60. this.logger = options.logger ?? new import_logger.NoopLogger();
  61. }
  62. static [import_entity.entityKind] = "PrismaSQLiteSession";
  63. logger;
  64. prepareQuery(query, fields, executeMethod) {
  65. return new PrismaSQLitePreparedQuery(this.prisma, query, this.logger, executeMethod);
  66. }
  67. transaction(_transaction, _config) {
  68. throw new Error("Method not implemented.");
  69. }
  70. }
  71. // Annotate the CommonJS export names for ESM import in node:
  72. 0 && (module.exports = {
  73. PrismaSQLitePreparedQuery,
  74. PrismaSQLiteSession
  75. });
  76. //# sourceMappingURL=session.cjs.map