@tachybase/database 0.23.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -0
- package/LICENSE +201 -0
- package/lib/collection-factory.d.ts +17 -0
- package/lib/collection-factory.js +52 -0
- package/lib/collection-group-manager.d.ts +26 -0
- package/lib/collection-group-manager.js +57 -0
- package/lib/collection-importer.d.ts +7 -0
- package/lib/collection-importer.js +74 -0
- package/lib/collection.d.ts +138 -0
- package/lib/collection.js +686 -0
- package/lib/database-utils/index.d.ts +9 -0
- package/lib/database-utils/index.js +71 -0
- package/lib/database-utils/traverseJSON.d.ts +10 -0
- package/lib/database-utils/traverseJSON.js +126 -0
- package/lib/database.d.ts +201 -0
- package/lib/database.js +765 -0
- package/lib/decorators/must-have-filter-decorator.d.ts +2 -0
- package/lib/decorators/must-have-filter-decorator.js +38 -0
- package/lib/decorators/target-collection-decorator.d.ts +2 -0
- package/lib/decorators/target-collection-decorator.js +47 -0
- package/lib/decorators/transaction-decorator.d.ts +1 -0
- package/lib/decorators/transaction-decorator.js +88 -0
- package/lib/eager-loading/eager-loading-tree.d.ts +31 -0
- package/lib/eager-loading/eager-loading-tree.js +439 -0
- package/lib/errors/identifier-error.d.ts +3 -0
- package/lib/errors/identifier-error.js +35 -0
- package/lib/errors/zero-column-table-error.d.ts +2 -0
- package/lib/errors/zero-column-table-error.js +31 -0
- package/lib/features/references-map.d.ts +18 -0
- package/lib/features/references-map.js +109 -0
- package/lib/features/referential-integrity-check.d.ts +8 -0
- package/lib/features/referential-integrity-check.js +83 -0
- package/lib/field-repository/array-field-repository.d.ts +28 -0
- package/lib/field-repository/array-field-repository.js +197 -0
- package/lib/fields/array-field.d.ts +11 -0
- package/lib/fields/array-field.js +57 -0
- package/lib/fields/belongs-to-field.d.ts +17 -0
- package/lib/fields/belongs-to-field.js +154 -0
- package/lib/fields/belongs-to-many-field.d.ts +20 -0
- package/lib/fields/belongs-to-many-field.js +187 -0
- package/lib/fields/boolean-field.d.ts +8 -0
- package/lib/fields/boolean-field.js +36 -0
- package/lib/fields/context-field.d.ts +14 -0
- package/lib/fields/context-field.js +70 -0
- package/lib/fields/date-field.d.ts +13 -0
- package/lib/fields/date-field.js +64 -0
- package/lib/fields/field.d.ts +43 -0
- package/lib/fields/field.js +156 -0
- package/lib/fields/has-inverse-field.d.ts +4 -0
- package/lib/fields/has-inverse-field.js +15 -0
- package/lib/fields/has-many-field.d.ts +68 -0
- package/lib/fields/has-many-field.js +156 -0
- package/lib/fields/has-one-field.d.ts +68 -0
- package/lib/fields/has-one-field.js +150 -0
- package/lib/fields/index.d.ts +46 -0
- package/lib/fields/index.js +65 -0
- package/lib/fields/json-field.d.ts +14 -0
- package/lib/fields/json-field.js +54 -0
- package/lib/fields/nanoid-field.d.ts +13 -0
- package/lib/fields/nanoid-field.js +58 -0
- package/lib/fields/number-field.d.ts +41 -0
- package/lib/fields/number-field.js +85 -0
- package/lib/fields/password-field.d.ts +21 -0
- package/lib/fields/password-field.js +95 -0
- package/lib/fields/radio-field.d.ts +16 -0
- package/lib/fields/radio-field.js +66 -0
- package/lib/fields/relation-field.d.ts +21 -0
- package/lib/fields/relation-field.js +79 -0
- package/lib/fields/set-field.d.ts +10 -0
- package/lib/fields/set-field.js +46 -0
- package/lib/fields/sort-field.d.ts +16 -0
- package/lib/fields/sort-field.js +187 -0
- package/lib/fields/string-field.d.ts +8 -0
- package/lib/fields/string-field.js +36 -0
- package/lib/fields/text-field.d.ts +8 -0
- package/lib/fields/text-field.js +36 -0
- package/lib/fields/time-field.d.ts +8 -0
- package/lib/fields/time-field.js +36 -0
- package/lib/fields/uid-field.d.ts +13 -0
- package/lib/fields/uid-field.js +63 -0
- package/lib/fields/uuid-field.d.ts +9 -0
- package/lib/fields/uuid-field.js +45 -0
- package/lib/fields/virtual-field.d.ts +8 -0
- package/lib/fields/virtual-field.js +36 -0
- package/lib/filter-match.d.ts +1 -0
- package/lib/filter-match.js +66 -0
- package/lib/filter-parser.d.ts +21 -0
- package/lib/filter-parser.js +230 -0
- package/lib/helpers.d.ts +3 -0
- package/lib/helpers.js +167 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +114 -0
- package/lib/inherited-collection.d.ts +14 -0
- package/lib/inherited-collection.js +138 -0
- package/lib/inherited-map.d.ts +21 -0
- package/lib/inherited-map.js +113 -0
- package/lib/inherited-sync-runner.d.ts +4 -0
- package/lib/inherited-sync-runner.js +175 -0
- package/lib/listeners/adjacency-list.d.ts +2 -0
- package/lib/listeners/adjacency-list.js +42 -0
- package/lib/listeners/append-child-collection-name-after-repository-find.d.ts +6 -0
- package/lib/listeners/append-child-collection-name-after-repository-find.js +66 -0
- package/lib/listeners/index.d.ts +2 -0
- package/lib/listeners/index.js +33 -0
- package/lib/magic-attribute-model.d.ts +8 -0
- package/lib/magic-attribute-model.js +203 -0
- package/lib/migration.d.ts +35 -0
- package/lib/migration.js +103 -0
- package/lib/mock-database.d.ts +25 -0
- package/lib/mock-database.js +126 -0
- package/lib/model-hook.d.ts +12 -0
- package/lib/model-hook.js +92 -0
- package/lib/model.d.ts +23 -0
- package/lib/model.js +152 -0
- package/lib/operators/array.d.ts +2 -0
- package/lib/operators/array.js +158 -0
- package/lib/operators/association.d.ts +2 -0
- package/lib/operators/association.js +35 -0
- package/lib/operators/boolean.d.ts +2 -0
- package/lib/operators/boolean.js +38 -0
- package/lib/operators/child-collection.d.ts +2 -0
- package/lib/operators/child-collection.js +67 -0
- package/lib/operators/date.d.ts +2 -0
- package/lib/operators/date.js +140 -0
- package/lib/operators/empty.d.ts +5 -0
- package/lib/operators/empty.js +89 -0
- package/lib/operators/eq.d.ts +2 -0
- package/lib/operators/eq.js +35 -0
- package/lib/operators/index.d.ts +5 -0
- package/lib/operators/index.js +56 -0
- package/lib/operators/jsonb.d.ts +2 -0
- package/lib/operators/jsonb.js +50 -0
- package/lib/operators/ne.d.ts +2 -0
- package/lib/operators/ne.js +40 -0
- package/lib/operators/notIn.d.ts +2 -0
- package/lib/operators/notIn.js +33 -0
- package/lib/operators/string.d.ts +2 -0
- package/lib/operators/string.js +109 -0
- package/lib/operators/utils.d.ts +4 -0
- package/lib/operators/utils.js +40 -0
- package/lib/options-parser.d.ts +37 -0
- package/lib/options-parser.js +332 -0
- package/lib/playground.d.ts +1 -0
- package/lib/playground.js +43 -0
- package/lib/query-interface/mysql-query-interface.d.ts +35 -0
- package/lib/query-interface/mysql-query-interface.js +122 -0
- package/lib/query-interface/postgres-query-interface.d.ts +32 -0
- package/lib/query-interface/postgres-query-interface.js +189 -0
- package/lib/query-interface/query-interface-builder.d.ts +2 -0
- package/lib/query-interface/query-interface-builder.js +46 -0
- package/lib/query-interface/query-interface.d.ts +42 -0
- package/lib/query-interface/query-interface.js +46 -0
- package/lib/query-interface/sqlite-query-interface.d.ts +35 -0
- package/lib/query-interface/sqlite-query-interface.js +131 -0
- package/lib/relation-repository/belongs-to-many-repository.d.ts +21 -0
- package/lib/relation-repository/belongs-to-many-repository.js +280 -0
- package/lib/relation-repository/belongs-to-repository.d.ts +6 -0
- package/lib/relation-repository/belongs-to-repository.js +39 -0
- package/lib/relation-repository/hasmany-repository.d.ts +10 -0
- package/lib/relation-repository/hasmany-repository.js +182 -0
- package/lib/relation-repository/hasone-repository.d.ts +6 -0
- package/lib/relation-repository/hasone-repository.js +39 -0
- package/lib/relation-repository/multiple-relation-repository.d.ts +20 -0
- package/lib/relation-repository/multiple-relation-repository.js +229 -0
- package/lib/relation-repository/relation-repository.d.ts +29 -0
- package/lib/relation-repository/relation-repository.js +202 -0
- package/lib/relation-repository/single-relation-repository.d.ts +25 -0
- package/lib/relation-repository/single-relation-repository.js +162 -0
- package/lib/relation-repository/types.d.ts +7 -0
- package/lib/relation-repository/types.js +15 -0
- package/lib/repositories/tree-repository/adjacency-list-repository.d.ts +18 -0
- package/lib/repositories/tree-repository/adjacency-list-repository.js +183 -0
- package/lib/repositories/view-repository.d.ts +3 -0
- package/lib/repositories/view-repository.js +32 -0
- package/lib/repository.d.ts +206 -0
- package/lib/repository.js +597 -0
- package/lib/sql-collection/index.d.ts +2 -0
- package/lib/sql-collection/index.js +23 -0
- package/lib/sql-collection/query-generator.d.ts +10 -0
- package/lib/sql-collection/query-generator.js +70 -0
- package/lib/sql-collection/sql-collection.d.ts +7 -0
- package/lib/sql-collection/sql-collection.js +69 -0
- package/lib/sql-collection/sql-model.d.ts +16 -0
- package/lib/sql-collection/sql-model.js +168 -0
- package/lib/sql-parser/index.d.ts +10 -0
- package/lib/sql-parser/index.js +10699 -0
- package/lib/sql-parser/postgres.d.ts +10 -0
- package/lib/sql-parser/postgres.js +31506 -0
- package/lib/sql-parser/sql.pegjs +1297 -0
- package/lib/sync-runner.d.ts +30 -0
- package/lib/sync-runner.js +277 -0
- package/lib/types.d.ts +49 -0
- package/lib/types.js +15 -0
- package/lib/update-associations.d.ts +60 -0
- package/lib/update-associations.js +405 -0
- package/lib/update-guard.d.ts +28 -0
- package/lib/update-guard.js +202 -0
- package/lib/utils.d.ts +7 -0
- package/lib/utils.js +127 -0
- package/lib/value-parsers/array-value-parser.d.ts +8 -0
- package/lib/value-parsers/array-value-parser.js +58 -0
- package/lib/value-parsers/base-value-parser.d.ts +12 -0
- package/lib/value-parsers/base-value-parser.js +63 -0
- package/lib/value-parsers/boolean-value-parser.d.ts +4 -0
- package/lib/value-parsers/boolean-value-parser.js +52 -0
- package/lib/value-parsers/date-value-parser.d.ts +5 -0
- package/lib/value-parsers/date-value-parser.js +88 -0
- package/lib/value-parsers/index.d.ts +12 -0
- package/lib/value-parsers/index.js +78 -0
- package/lib/value-parsers/json-value-parser.d.ts +4 -0
- package/lib/value-parsers/json-value-parser.js +47 -0
- package/lib/value-parsers/number-value-parser.d.ts +4 -0
- package/lib/value-parsers/number-value-parser.js +58 -0
- package/lib/value-parsers/string-value-parser.d.ts +8 -0
- package/lib/value-parsers/string-value-parser.js +64 -0
- package/lib/value-parsers/to-many-value-parser.d.ts +13 -0
- package/lib/value-parsers/to-many-value-parser.js +108 -0
- package/lib/value-parsers/to-one-value-parser.d.ts +4 -0
- package/lib/value-parsers/to-one-value-parser.js +48 -0
- package/lib/view/field-type-map.d.ts +97 -0
- package/lib/view/field-type-map.js +90 -0
- package/lib/view/view-inference.d.ts +32 -0
- package/lib/view/view-inference.js +146 -0
- package/lib/view-collection.d.ts +6 -0
- package/lib/view-collection.js +45 -0
- package/package.json +38 -0
package/lib/model.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
|
+
var model_exports = {};
|
|
32
|
+
__export(model_exports, {
|
|
33
|
+
Model: () => Model
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(model_exports);
|
|
36
|
+
var import_lodash = __toESM(require("lodash"));
|
|
37
|
+
var import_sequelize = require("sequelize");
|
|
38
|
+
var import_sync_runner = require("./sync-runner");
|
|
39
|
+
const _ = import_lodash.default;
|
|
40
|
+
const _Model = class _Model extends import_sequelize.Model {
|
|
41
|
+
_changedWithAssociations = /* @__PURE__ */ new Set();
|
|
42
|
+
_previousDataValuesWithAssociations = {};
|
|
43
|
+
get db() {
|
|
44
|
+
return this.constructor.database;
|
|
45
|
+
}
|
|
46
|
+
static async sync(options) {
|
|
47
|
+
const runner = new import_sync_runner.SyncRunner(this);
|
|
48
|
+
return runner.runSync(options);
|
|
49
|
+
}
|
|
50
|
+
// TODO
|
|
51
|
+
toChangedWithAssociations() {
|
|
52
|
+
this._changedWithAssociations = /* @__PURE__ */ new Set([...this._changedWithAssociations, ...this._changed]);
|
|
53
|
+
this._previousDataValuesWithAssociations = this._previousDataValues;
|
|
54
|
+
}
|
|
55
|
+
changedWithAssociations(key, value) {
|
|
56
|
+
if (key === void 0) {
|
|
57
|
+
if (this._changedWithAssociations.size > 0) {
|
|
58
|
+
return Array.from(this._changedWithAssociations);
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (value === true) {
|
|
63
|
+
this._changedWithAssociations.add(key);
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
if (value === false) {
|
|
67
|
+
this._changedWithAssociations.delete(key);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
return this._changedWithAssociations.has(key);
|
|
71
|
+
}
|
|
72
|
+
clearChangedWithAssociations() {
|
|
73
|
+
this._changedWithAssociations = /* @__PURE__ */ new Set();
|
|
74
|
+
}
|
|
75
|
+
toJSON() {
|
|
76
|
+
const handleObj = /* @__PURE__ */ __name((obj, options) => {
|
|
77
|
+
const handles = [
|
|
78
|
+
(data) => {
|
|
79
|
+
if (data instanceof _Model) {
|
|
80
|
+
return data.toJSON();
|
|
81
|
+
}
|
|
82
|
+
return data;
|
|
83
|
+
},
|
|
84
|
+
this.hiddenObjKey
|
|
85
|
+
];
|
|
86
|
+
return handles.reduce((carry, fn) => fn.apply(this, [carry, options]), obj);
|
|
87
|
+
}, "handleObj");
|
|
88
|
+
const handleArray = /* @__PURE__ */ __name((arrayOfObj, options) => {
|
|
89
|
+
const handles = [this.sortAssociations];
|
|
90
|
+
return handles.reduce((carry, fn) => fn.apply(this, [carry, options]), arrayOfObj || []);
|
|
91
|
+
}, "handleArray");
|
|
92
|
+
const opts = {
|
|
93
|
+
model: this.constructor,
|
|
94
|
+
collection: this.constructor.collection,
|
|
95
|
+
db: this.constructor.database
|
|
96
|
+
};
|
|
97
|
+
const traverseJSON = /* @__PURE__ */ __name((data, options) => {
|
|
98
|
+
const { model, db, collection } = options;
|
|
99
|
+
data = handleObj(data, options);
|
|
100
|
+
const result = {};
|
|
101
|
+
for (const key of Object.keys(data)) {
|
|
102
|
+
if (model.hasAlias(key)) {
|
|
103
|
+
const association = model.associations[key];
|
|
104
|
+
const opts2 = {
|
|
105
|
+
model: association.target,
|
|
106
|
+
collection: db.getCollection(association.target.name),
|
|
107
|
+
db,
|
|
108
|
+
key,
|
|
109
|
+
field: collection.getField(key)
|
|
110
|
+
};
|
|
111
|
+
if (["HasMany", "BelongsToMany"].includes(association.associationType)) {
|
|
112
|
+
result[key] = handleArray(data[key], opts2).map((item) => traverseJSON(item, opts2));
|
|
113
|
+
} else {
|
|
114
|
+
result[key] = data[key] ? traverseJSON(data[key], opts2) : null;
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
result[key] = data[key];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}, "traverseJSON");
|
|
122
|
+
return traverseJSON(super.toJSON(), opts);
|
|
123
|
+
}
|
|
124
|
+
hiddenObjKey(obj, options) {
|
|
125
|
+
const hiddenFields = Array.from(options.collection.fields.values()).filter((field) => field.options.hidden).map((field) => field.options.name);
|
|
126
|
+
return import_lodash.default.omit(obj, hiddenFields);
|
|
127
|
+
}
|
|
128
|
+
sortAssociations(data, { field }) {
|
|
129
|
+
const sortBy = field.options.sortBy;
|
|
130
|
+
return sortBy ? this.sortArray(data, sortBy) : data;
|
|
131
|
+
}
|
|
132
|
+
sortArray(data, sortBy) {
|
|
133
|
+
if (!import_lodash.default.isArray(sortBy)) {
|
|
134
|
+
sortBy = [sortBy];
|
|
135
|
+
}
|
|
136
|
+
const orderItems = [];
|
|
137
|
+
const orderDirections = [];
|
|
138
|
+
sortBy.forEach((sortItem) => {
|
|
139
|
+
orderDirections.push(sortItem.startsWith("-") ? "desc" : "asc");
|
|
140
|
+
orderItems.push(sortItem.replace("-", ""));
|
|
141
|
+
});
|
|
142
|
+
return import_lodash.default.orderBy(data, orderItems, orderDirections);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
__name(_Model, "Model");
|
|
146
|
+
__publicField(_Model, "database");
|
|
147
|
+
__publicField(_Model, "collection");
|
|
148
|
+
let Model = _Model;
|
|
149
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
150
|
+
0 && (module.exports = {
|
|
151
|
+
Model
|
|
152
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var array_exports = {};
|
|
30
|
+
__export(array_exports, {
|
|
31
|
+
default: () => array_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(array_exports);
|
|
34
|
+
var import_lodash = __toESM(require("lodash"));
|
|
35
|
+
var import_sequelize = require("sequelize");
|
|
36
|
+
var import_utils = require("./utils");
|
|
37
|
+
const getFieldName = /* @__PURE__ */ __name((ctx) => {
|
|
38
|
+
const fieldName = ctx.fieldName;
|
|
39
|
+
return fieldName;
|
|
40
|
+
}, "getFieldName");
|
|
41
|
+
const escape = /* @__PURE__ */ __name((value, ctx) => {
|
|
42
|
+
const sequelize = ctx.db.sequelize;
|
|
43
|
+
return sequelize.escape(value);
|
|
44
|
+
}, "escape");
|
|
45
|
+
const getQueryInterface = /* @__PURE__ */ __name((ctx) => {
|
|
46
|
+
const sequelize = ctx.db.sequelize;
|
|
47
|
+
return sequelize.getQueryInterface();
|
|
48
|
+
}, "getQueryInterface");
|
|
49
|
+
const sqliteExistQuery = /* @__PURE__ */ __name((value, ctx) => {
|
|
50
|
+
const fieldName = getFieldName(ctx);
|
|
51
|
+
const name = ctx.fullName === fieldName ? `"${ctx.model.name}"."${fieldName}"` : `"${fieldName}"`;
|
|
52
|
+
const sqlArray = `(${value.map((v) => `'${v}'`).join(", ")})`;
|
|
53
|
+
const subQuery = `exists (select * from json_each(${name}) where json_each.value in ${sqlArray})`;
|
|
54
|
+
return subQuery;
|
|
55
|
+
}, "sqliteExistQuery");
|
|
56
|
+
const emptyQuery = /* @__PURE__ */ __name((ctx, operator) => {
|
|
57
|
+
const fieldName = getFieldName(ctx);
|
|
58
|
+
let funcName = "json_array_length";
|
|
59
|
+
let ifNull = "IFNULL";
|
|
60
|
+
if ((0, import_utils.isPg)(ctx)) {
|
|
61
|
+
funcName = "jsonb_array_length";
|
|
62
|
+
ifNull = "coalesce";
|
|
63
|
+
}
|
|
64
|
+
if ((0, import_utils.isMySQL)(ctx)) {
|
|
65
|
+
funcName = "json_length";
|
|
66
|
+
}
|
|
67
|
+
return `(select ${ifNull}(${funcName}(${fieldName}), 0) ${operator} 0)`;
|
|
68
|
+
}, "emptyQuery");
|
|
69
|
+
var array_default = {
|
|
70
|
+
$match(value, ctx) {
|
|
71
|
+
const fieldName = getFieldName(ctx);
|
|
72
|
+
if ((0, import_utils.isPg)(ctx)) {
|
|
73
|
+
const name = ctx.fullName === fieldName ? `"${ctx.model.name}"."${fieldName}"` : `"${fieldName}"`;
|
|
74
|
+
const queryValue = escape(JSON.stringify(value), ctx);
|
|
75
|
+
return import_sequelize.Sequelize.literal(`${name} @> ${queryValue}::JSONB AND ${name} <@ ${queryValue}::JSONB`);
|
|
76
|
+
}
|
|
77
|
+
value = escape(JSON.stringify(value.sort()), ctx);
|
|
78
|
+
if ((0, import_utils.isMySQL)(ctx)) {
|
|
79
|
+
const name = ctx.fullName === fieldName ? `\`${ctx.model.name}\`.\`${fieldName}\`` : `\`${fieldName}\``;
|
|
80
|
+
return import_sequelize.Sequelize.literal(`JSON_CONTAINS(${name}, ${value}) AND JSON_CONTAINS(${value}, ${name})`);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
[import_sequelize.Op.eq]: import_sequelize.Sequelize.literal(`json(${value})`)
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
$notMatch(value, ctx) {
|
|
87
|
+
const fieldName = getFieldName(ctx);
|
|
88
|
+
value = escape(JSON.stringify(value), ctx);
|
|
89
|
+
if ((0, import_utils.isPg)(ctx)) {
|
|
90
|
+
const name = ctx.fullName === fieldName ? `"${ctx.model.name}"."${fieldName}"` : `"${fieldName}"`;
|
|
91
|
+
return import_sequelize.Sequelize.literal(`not (${name} <@ ${value}::JSONB and ${name} @> ${value}::JSONB)`);
|
|
92
|
+
}
|
|
93
|
+
if ((0, import_utils.isMySQL)(ctx)) {
|
|
94
|
+
const name = ctx.fullName === fieldName ? `\`${ctx.model.name}\`.\`${fieldName}\`` : `\`${fieldName}\``;
|
|
95
|
+
return import_sequelize.Sequelize.literal(`not (JSON_CONTAINS(${name}, ${value}) AND JSON_CONTAINS(${value}, ${name}))`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
[import_sequelize.Op.ne]: import_sequelize.Sequelize.literal(`json(${value})`)
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
$anyOf(value, ctx) {
|
|
102
|
+
const fieldName = getFieldName(ctx);
|
|
103
|
+
value = import_lodash.default.castArray(value);
|
|
104
|
+
if ((0, import_utils.isPg)(ctx)) {
|
|
105
|
+
const name = ctx.fullName === fieldName ? `"${ctx.model.name}"."${fieldName}"` : `"${fieldName}"`;
|
|
106
|
+
return import_sequelize.Sequelize.literal(
|
|
107
|
+
`${name} ?| ${escape(
|
|
108
|
+
value.map((i) => `${i}`),
|
|
109
|
+
ctx
|
|
110
|
+
)}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if ((0, import_utils.isMySQL)(ctx)) {
|
|
114
|
+
value = escape(JSON.stringify(value), ctx);
|
|
115
|
+
const name = ctx.fullName === fieldName ? `\`${ctx.model.name}\`.\`${fieldName}\`` : `\`${fieldName}\``;
|
|
116
|
+
return import_sequelize.Sequelize.literal(`JSON_OVERLAPS(${name}, ${value})`);
|
|
117
|
+
}
|
|
118
|
+
const subQuery = sqliteExistQuery(value, ctx);
|
|
119
|
+
return import_sequelize.Sequelize.literal(subQuery);
|
|
120
|
+
},
|
|
121
|
+
$noneOf(value, ctx) {
|
|
122
|
+
let where;
|
|
123
|
+
value = import_lodash.default.castArray(value);
|
|
124
|
+
if ((0, import_utils.isPg)(ctx)) {
|
|
125
|
+
const fieldName = getFieldName(ctx);
|
|
126
|
+
const name = ctx.fullName === fieldName ? `"${ctx.model.name}"."${fieldName}"` : `"${fieldName}"`;
|
|
127
|
+
where = import_sequelize.Sequelize.literal(
|
|
128
|
+
`not (${name} ?| ${escape(
|
|
129
|
+
value.map((i) => `${i}`),
|
|
130
|
+
ctx
|
|
131
|
+
)})`
|
|
132
|
+
);
|
|
133
|
+
} else if ((0, import_utils.isMySQL)(ctx)) {
|
|
134
|
+
const fieldName = getFieldName(ctx);
|
|
135
|
+
value = escape(JSON.stringify(value), ctx);
|
|
136
|
+
const name = ctx.fullName === fieldName ? `\`${ctx.model.name}\`.\`${fieldName}\`` : `\`${fieldName}\``;
|
|
137
|
+
where = import_sequelize.Sequelize.literal(`NOT JSON_OVERLAPS(${name}, ${value})`);
|
|
138
|
+
} else {
|
|
139
|
+
const subQuery = sqliteExistQuery(value, ctx);
|
|
140
|
+
where = import_sequelize.Sequelize.literal(`not ${subQuery}`);
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
[import_sequelize.Op.or]: [where, { [import_sequelize.Op.is]: null }]
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
$arrayEmpty(value, ctx) {
|
|
147
|
+
const subQuery = emptyQuery(ctx, "=");
|
|
148
|
+
return {
|
|
149
|
+
[import_sequelize.Op.and]: [import_sequelize.Sequelize.literal(`${subQuery}`)]
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
$arrayNotEmpty(value, ctx) {
|
|
153
|
+
const subQuery = emptyQuery(ctx, ">");
|
|
154
|
+
return {
|
|
155
|
+
[import_sequelize.Op.and]: [import_sequelize.Sequelize.literal(`${subQuery}`)]
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var association_exports = {};
|
|
19
|
+
__export(association_exports, {
|
|
20
|
+
default: () => association_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(association_exports);
|
|
23
|
+
var import_sequelize = require("sequelize");
|
|
24
|
+
var association_default = {
|
|
25
|
+
$exists(value, ctx) {
|
|
26
|
+
return {
|
|
27
|
+
[import_sequelize.Op.not]: null
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
$notExists(value, ctx) {
|
|
31
|
+
return {
|
|
32
|
+
[import_sequelize.Op.is]: null
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var boolean_exports = {};
|
|
19
|
+
__export(boolean_exports, {
|
|
20
|
+
default: () => boolean_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(boolean_exports);
|
|
23
|
+
var import_sequelize = require("sequelize");
|
|
24
|
+
var boolean_default = {
|
|
25
|
+
$isFalsy() {
|
|
26
|
+
return {
|
|
27
|
+
[import_sequelize.Op.or]: {
|
|
28
|
+
[import_sequelize.Op.is]: null,
|
|
29
|
+
[import_sequelize.Op.eq]: false
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
$isTruly() {
|
|
34
|
+
return {
|
|
35
|
+
[import_sequelize.Op.eq]: true
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var child_collection_exports = {};
|
|
30
|
+
__export(child_collection_exports, {
|
|
31
|
+
default: () => child_collection_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(child_collection_exports);
|
|
34
|
+
var import_lodash = __toESM(require("lodash"));
|
|
35
|
+
var import_sequelize = require("sequelize");
|
|
36
|
+
const mapVal = /* @__PURE__ */ __name((values, db) => values.map((v) => {
|
|
37
|
+
const collection = db.getCollection(v);
|
|
38
|
+
return import_sequelize.Sequelize.literal(`'${collection.tableNameAsString()}'::regclass`);
|
|
39
|
+
}), "mapVal");
|
|
40
|
+
const filterItems = /* @__PURE__ */ __name((values, db) => {
|
|
41
|
+
return import_lodash.default.castArray(values).map((v) => {
|
|
42
|
+
const collection = db.getCollection(v);
|
|
43
|
+
if (!collection) return null;
|
|
44
|
+
return `'${collection.tableNameAsString()}'::regclass`;
|
|
45
|
+
}).filter(Boolean);
|
|
46
|
+
}, "filterItems");
|
|
47
|
+
const joinValues = /* @__PURE__ */ __name((items) => items.join(", "), "joinValues");
|
|
48
|
+
var child_collection_default = {
|
|
49
|
+
$childIn(values, ctx) {
|
|
50
|
+
const db = ctx.db;
|
|
51
|
+
const items = filterItems(values, db);
|
|
52
|
+
if (items.length) {
|
|
53
|
+
return import_sequelize.Sequelize.literal(`"${ctx.model.name}"."tableoid" IN (${joinValues(items)})`);
|
|
54
|
+
} else {
|
|
55
|
+
return import_sequelize.Sequelize.literal(`1 = 2`);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
$childNotIn(values, ctx) {
|
|
59
|
+
const db = ctx.db;
|
|
60
|
+
const items = filterItems(values, db);
|
|
61
|
+
if (items.length) {
|
|
62
|
+
return import_sequelize.Sequelize.literal(`"${ctx.model.name}"."tableoid" NOT IN (${joinValues(items)})`);
|
|
63
|
+
} else {
|
|
64
|
+
return import_sequelize.Sequelize.literal(`1 = 1`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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 date_exports = {};
|
|
20
|
+
__export(date_exports, {
|
|
21
|
+
default: () => date_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(date_exports);
|
|
24
|
+
var import_utils = require("@tachybase/utils");
|
|
25
|
+
var import_sequelize = require("sequelize");
|
|
26
|
+
function isDate(input) {
|
|
27
|
+
return input instanceof Date || Object.prototype.toString.call(input) === "[object Date]";
|
|
28
|
+
}
|
|
29
|
+
__name(isDate, "isDate");
|
|
30
|
+
const toDate = /* @__PURE__ */ __name((date) => {
|
|
31
|
+
if (isDate(date)) {
|
|
32
|
+
return date;
|
|
33
|
+
}
|
|
34
|
+
return new Date(date);
|
|
35
|
+
}, "toDate");
|
|
36
|
+
var date_default = {
|
|
37
|
+
$dateOn(value, ctx) {
|
|
38
|
+
const r = (0, import_utils.parseDate)(value, {
|
|
39
|
+
timezone: ctx.db.options.timezone
|
|
40
|
+
});
|
|
41
|
+
if (typeof r === "string") {
|
|
42
|
+
return {
|
|
43
|
+
[import_sequelize.Op.eq]: toDate(r)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(r)) {
|
|
47
|
+
return {
|
|
48
|
+
[import_sequelize.Op.and]: [{ [import_sequelize.Op.gte]: toDate(r[0]) }, { [import_sequelize.Op.lt]: toDate(r[1]) }]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Invalid Date ${JSON.stringify(value)}`);
|
|
52
|
+
},
|
|
53
|
+
$dateNotOn(value, ctx) {
|
|
54
|
+
const r = (0, import_utils.parseDate)(value, {
|
|
55
|
+
timezone: ctx.db.options.timezone
|
|
56
|
+
});
|
|
57
|
+
if (typeof r === "string") {
|
|
58
|
+
return {
|
|
59
|
+
[import_sequelize.Op.ne]: toDate(r)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(r)) {
|
|
63
|
+
return {
|
|
64
|
+
[import_sequelize.Op.or]: [{ [import_sequelize.Op.lt]: toDate(r[0]) }, { [import_sequelize.Op.gte]: toDate(r[1]) }]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`Invalid Date ${JSON.stringify(value)}`);
|
|
68
|
+
},
|
|
69
|
+
$dateBefore(value, ctx) {
|
|
70
|
+
const r = (0, import_utils.parseDate)(value, {
|
|
71
|
+
timezone: ctx.db.options.timezone
|
|
72
|
+
});
|
|
73
|
+
if (typeof r === "string") {
|
|
74
|
+
return {
|
|
75
|
+
[import_sequelize.Op.lt]: toDate(r)
|
|
76
|
+
};
|
|
77
|
+
} else if (Array.isArray(r)) {
|
|
78
|
+
return {
|
|
79
|
+
[import_sequelize.Op.lt]: toDate(r[0])
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
throw new Error(`Invalid Date ${JSON.stringify(value)}`);
|
|
83
|
+
},
|
|
84
|
+
$dateNotBefore(value, ctx) {
|
|
85
|
+
const r = (0, import_utils.parseDate)(value, {
|
|
86
|
+
timezone: ctx.db.options.timezone
|
|
87
|
+
});
|
|
88
|
+
if (typeof r === "string") {
|
|
89
|
+
return {
|
|
90
|
+
[import_sequelize.Op.gte]: toDate(r)
|
|
91
|
+
};
|
|
92
|
+
} else if (Array.isArray(r)) {
|
|
93
|
+
return {
|
|
94
|
+
[import_sequelize.Op.gte]: toDate(r[0])
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
throw new Error(`Invalid Date ${JSON.stringify(value)}`);
|
|
98
|
+
},
|
|
99
|
+
$dateAfter(value, ctx) {
|
|
100
|
+
const r = (0, import_utils.parseDate)(value, {
|
|
101
|
+
timezone: ctx.db.options.timezone
|
|
102
|
+
});
|
|
103
|
+
if (typeof r === "string") {
|
|
104
|
+
return {
|
|
105
|
+
[import_sequelize.Op.gt]: toDate(r)
|
|
106
|
+
};
|
|
107
|
+
} else if (Array.isArray(r)) {
|
|
108
|
+
return {
|
|
109
|
+
[import_sequelize.Op.gte]: toDate(r[1])
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
throw new Error(`Invalid Date ${JSON.stringify(value)}`);
|
|
113
|
+
},
|
|
114
|
+
$dateNotAfter(value, ctx) {
|
|
115
|
+
const r = (0, import_utils.parseDate)(value, {
|
|
116
|
+
timezone: ctx.db.options.timezone
|
|
117
|
+
});
|
|
118
|
+
if (typeof r === "string") {
|
|
119
|
+
return {
|
|
120
|
+
[import_sequelize.Op.lte]: toDate(r)
|
|
121
|
+
};
|
|
122
|
+
} else if (Array.isArray(r)) {
|
|
123
|
+
return {
|
|
124
|
+
[import_sequelize.Op.lt]: toDate(r[1])
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
throw new Error(`Invalid Date ${JSON.stringify(value)}`);
|
|
128
|
+
},
|
|
129
|
+
$dateBetween(value, ctx) {
|
|
130
|
+
const r = (0, import_utils.parseDate)(value, {
|
|
131
|
+
timezone: ctx.db.options.timezone
|
|
132
|
+
});
|
|
133
|
+
if (r) {
|
|
134
|
+
return {
|
|
135
|
+
[import_sequelize.Op.and]: [{ [import_sequelize.Op.gte]: toDate(r[0]) }, { [import_sequelize.Op.lt]: toDate(r[1]) }]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
throw new Error(`Invalid Date ${JSON.stringify(value)}`);
|
|
139
|
+
}
|
|
140
|
+
};
|