session.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { entityKind } from "../../entity.js";
  2. import { NoopLogger } from "../../logger.js";
  3. import { PgPreparedQuery, PgSession } from "../../pg-core/index.js";
  4. import { fillPlaceholders } from "../../sql/sql.js";
  5. class PrismaPgPreparedQuery extends PgPreparedQuery {
  6. constructor(prisma, query, logger) {
  7. super(query, void 0, void 0, void 0);
  8. this.prisma = prisma;
  9. this.logger = logger;
  10. }
  11. static [entityKind] = "PrismaPgPreparedQuery";
  12. execute(placeholderValues) {
  13. const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
  14. this.logger.logQuery(this.query.sql, params);
  15. return this.prisma.$queryRawUnsafe(this.query.sql, ...params);
  16. }
  17. all() {
  18. throw new Error("Method not implemented.");
  19. }
  20. isResponseInArrayMode() {
  21. return false;
  22. }
  23. }
  24. class PrismaPgSession extends PgSession {
  25. constructor(dialect, prisma, options) {
  26. super(dialect);
  27. this.prisma = prisma;
  28. this.options = options;
  29. this.logger = options.logger ?? new NoopLogger();
  30. }
  31. static [entityKind] = "PrismaPgSession";
  32. logger;
  33. execute(query) {
  34. return this.prepareQuery(this.dialect.sqlToQuery(query)).execute();
  35. }
  36. prepareQuery(query) {
  37. return new PrismaPgPreparedQuery(this.prisma, query, this.logger);
  38. }
  39. transaction(_transaction, _config) {
  40. throw new Error("Method not implemented.");
  41. }
  42. }
  43. export {
  44. PrismaPgPreparedQuery,
  45. PrismaPgSession
  46. };
  47. //# sourceMappingURL=session.js.map