indexes.cjs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 indexes_exports = {};
  20. __export(indexes_exports, {
  21. Index: () => Index,
  22. IndexBuilder: () => IndexBuilder,
  23. IndexBuilderOn: () => IndexBuilderOn,
  24. index: () => index,
  25. uniqueIndex: () => uniqueIndex
  26. });
  27. module.exports = __toCommonJS(indexes_exports);
  28. var import_entity = require("../entity.cjs");
  29. class IndexBuilderOn {
  30. constructor(name, unique) {
  31. this.name = name;
  32. this.unique = unique;
  33. }
  34. static [import_entity.entityKind] = "SQLiteIndexBuilderOn";
  35. on(...columns) {
  36. return new IndexBuilder(this.name, columns, this.unique);
  37. }
  38. }
  39. class IndexBuilder {
  40. static [import_entity.entityKind] = "SQLiteIndexBuilder";
  41. /** @internal */
  42. config;
  43. constructor(name, columns, unique) {
  44. this.config = {
  45. name,
  46. columns,
  47. unique,
  48. where: void 0
  49. };
  50. }
  51. /**
  52. * Condition for partial index.
  53. */
  54. where(condition) {
  55. this.config.where = condition;
  56. return this;
  57. }
  58. /** @internal */
  59. build(table) {
  60. return new Index(this.config, table);
  61. }
  62. }
  63. class Index {
  64. static [import_entity.entityKind] = "SQLiteIndex";
  65. config;
  66. constructor(config, table) {
  67. this.config = { ...config, table };
  68. }
  69. }
  70. function index(name) {
  71. return new IndexBuilderOn(name, false);
  72. }
  73. function uniqueIndex(name) {
  74. return new IndexBuilderOn(name, true);
  75. }
  76. // Annotate the CommonJS export names for ESM import in node:
  77. 0 && (module.exports = {
  78. Index,
  79. IndexBuilder,
  80. IndexBuilderOn,
  81. index,
  82. uniqueIndex
  83. });
  84. //# sourceMappingURL=indexes.cjs.map