@arcaelas/dynamite 1.0.29 → 3.1.0
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/README.md +13 -13
- package/{src → build/cjs}/@types/index.d.ts +26 -1
- package/build/cjs/@types/index.js.map +1 -0
- package/{src → build/cjs}/core/client.d.ts +22 -19
- package/build/cjs/core/client.js +384 -0
- package/build/cjs/core/client.js.map +1 -0
- package/build/cjs/core/decorator.d.ts +50 -0
- package/build/cjs/core/decorator.js +52 -0
- package/build/cjs/core/decorator.js.map +1 -0
- package/build/cjs/core/table.d.ts +73 -0
- package/build/cjs/core/table.js +953 -0
- package/build/cjs/core/table.js.map +1 -0
- package/build/cjs/decorators/hooks.d.ts +35 -0
- package/build/cjs/decorators/hooks.js +50 -0
- package/build/cjs/decorators/hooks.js.map +1 -0
- package/build/cjs/decorators/indexes.d.ts +20 -0
- package/build/cjs/decorators/indexes.js +45 -0
- package/build/cjs/decorators/indexes.js.map +1 -0
- package/{src → build/cjs}/decorators/relations.d.ts +8 -7
- package/{src → build/cjs}/decorators/relations.js +9 -8
- package/build/cjs/decorators/relations.js.map +1 -0
- package/build/cjs/decorators/timestamps.d.ts +20 -0
- package/build/cjs/decorators/timestamps.js +34 -0
- package/build/cjs/decorators/timestamps.js.map +1 -0
- package/build/cjs/decorators/transforms.d.ts +41 -0
- package/build/cjs/decorators/transforms.js +98 -0
- package/build/cjs/decorators/transforms.js.map +1 -0
- package/{src → build/cjs}/index.d.ts +7 -3
- package/{src → build/cjs}/index.js +15 -6
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/package.json +1 -0
- package/build/cjs/test/basic.d.ts +1 -0
- package/build/cjs/test/basic.js +248 -0
- package/build/cjs/test/basic.js.map +1 -0
- package/build/cjs/test/bulk.d.ts +1 -0
- package/build/cjs/test/bulk.js +108 -0
- package/build/cjs/test/bulk.js.map +1 -0
- package/build/cjs/test/contracts.d.ts +1 -0
- package/build/cjs/test/contracts.js +343 -0
- package/build/cjs/test/contracts.js.map +1 -0
- package/build/cjs/test/filters.d.ts +1 -0
- package/build/cjs/test/filters.js +190 -0
- package/build/cjs/test/filters.js.map +1 -0
- package/build/cjs/test/hooks.d.ts +1 -0
- package/build/cjs/test/hooks.js +191 -0
- package/build/cjs/test/hooks.js.map +1 -0
- package/build/cjs/test/index.js +38 -0
- package/build/cjs/test/index.js.map +1 -0
- package/build/cjs/test/query_scan.d.ts +1 -0
- package/build/cjs/test/query_scan.js +195 -0
- package/build/cjs/test/query_scan.js.map +1 -0
- package/build/cjs/test/relations.d.ts +1 -0
- package/build/cjs/test/relations.js +246 -0
- package/build/cjs/test/relations.js.map +1 -0
- package/build/cjs/test/transactions.d.ts +1 -0
- package/build/cjs/test/transactions.js +145 -0
- package/build/cjs/test/transactions.js.map +1 -0
- package/{src → build/cjs}/utils/relations.js +1 -8
- package/build/cjs/utils/relations.js.map +1 -0
- package/build/cjs/utils/ulid.d.ts +10 -0
- package/build/cjs/utils/ulid.js +55 -0
- package/build/cjs/utils/ulid.js.map +1 -0
- package/build/esm/@types/index.d.ts +213 -0
- package/build/esm/@types/index.js +8 -0
- package/build/esm/@types/index.js.map +1 -0
- package/build/esm/core/client.d.ts +96 -0
- package/build/esm/core/client.js +375 -0
- package/build/esm/core/client.js.map +1 -0
- package/build/esm/core/decorator.d.ts +50 -0
- package/build/esm/core/decorator.js +47 -0
- package/build/esm/core/decorator.js.map +1 -0
- package/build/esm/core/table.d.ts +73 -0
- package/build/esm/core/table.js +950 -0
- package/build/esm/core/table.js.map +1 -0
- package/build/esm/decorators/hooks.d.ts +35 -0
- package/build/esm/decorators/hooks.js +47 -0
- package/build/esm/decorators/hooks.js.map +1 -0
- package/build/esm/decorators/indexes.d.ts +20 -0
- package/build/esm/decorators/indexes.js +42 -0
- package/build/esm/decorators/indexes.js.map +1 -0
- package/build/esm/decorators/relations.d.ts +75 -0
- package/build/esm/decorators/relations.js +112 -0
- package/build/esm/decorators/relations.js.map +1 -0
- package/build/esm/decorators/timestamps.d.ts +20 -0
- package/build/esm/decorators/timestamps.js +31 -0
- package/build/esm/decorators/timestamps.js.map +1 -0
- package/build/esm/decorators/transforms.d.ts +41 -0
- package/build/esm/decorators/transforms.js +92 -0
- package/build/esm/decorators/transforms.js.map +1 -0
- package/build/esm/index.d.ts +19 -0
- package/build/esm/index.js +26 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/package.json +1 -0
- package/build/esm/test/basic.d.ts +1 -0
- package/build/esm/test/basic.js +245 -0
- package/build/esm/test/basic.js.map +1 -0
- package/build/esm/test/bulk.d.ts +1 -0
- package/build/esm/test/bulk.js +105 -0
- package/build/esm/test/bulk.js.map +1 -0
- package/build/esm/test/contracts.d.ts +1 -0
- package/build/esm/test/contracts.js +340 -0
- package/build/esm/test/contracts.js.map +1 -0
- package/build/esm/test/filters.d.ts +1 -0
- package/build/esm/test/filters.js +187 -0
- package/build/esm/test/filters.js.map +1 -0
- package/build/esm/test/hooks.d.ts +1 -0
- package/build/esm/test/hooks.js +188 -0
- package/build/esm/test/hooks.js.map +1 -0
- package/build/esm/test/index.d.ts +1 -0
- package/build/esm/test/index.js +33 -0
- package/build/esm/test/index.js.map +1 -0
- package/build/esm/test/query_scan.d.ts +1 -0
- package/build/esm/test/query_scan.js +192 -0
- package/build/esm/test/query_scan.js.map +1 -0
- package/build/esm/test/relations.d.ts +1 -0
- package/build/esm/test/relations.js +243 -0
- package/build/esm/test/relations.js.map +1 -0
- package/build/esm/test/transactions.d.ts +1 -0
- package/build/esm/test/transactions.js +142 -0
- package/build/esm/test/transactions.js.map +1 -0
- package/build/esm/utils/relations.d.ts +42 -0
- package/build/esm/utils/relations.js +207 -0
- package/build/esm/utils/relations.js.map +1 -0
- package/build/esm/utils/ulid.d.ts +10 -0
- package/build/esm/utils/ulid.js +52 -0
- package/build/esm/utils/ulid.js.map +1 -0
- package/package.json +31 -9
- package/src/core/client.js +0 -296
- package/src/core/decorator.d.ts +0 -29
- package/src/core/decorator.js +0 -103
- package/src/core/table.d.ts +0 -81
- package/src/core/table.js +0 -892
- package/src/decorators/indexes.d.ts +0 -38
- package/src/decorators/indexes.js +0 -59
- package/src/decorators/timestamps.d.ts +0 -54
- package/src/decorators/timestamps.js +0 -72
- package/src/decorators/transforms.d.ts +0 -99
- package/src/decorators/transforms.js +0 -166
- package/src/index.test.js +0 -37
- /package/{src → build/cjs}/@types/index.js +0 -0
- /package/{src/index.test.d.ts → build/cjs/test/index.d.ts} +0 -0
- /package/{src → build/cjs}/utils/relations.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../../src/utils/relations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAe3C;;;GAGG;AACH,MAAM,gBAAgB,GAAG,KAAK,EAC5B,KAAY,EACZ,QAAoE,EACpE,UAA0B,EAAE,EACC,EAAE;IAC/B,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxE,IAAI,CAAC,UAAU,CAAC,MAAM;QAAE,OAAO,IAAI,GAAG,EAAE,CAAC;IAEzC,uCAAuC;IACvC,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;IAEtC,+BAA+B;IAC/B,MAAM,OAAO,GAAwB;QACnC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE;QAC1C,GAAG,OAAO,CAAC,KAAK;KACjB,CAAC;IAEF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EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;YACzD,CAAC;YAED,mBAAmB;YACnB,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC;gBAClF,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE;gBACrB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;QAC5B,CAAC;QAED,uDAAuD;QACvD,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC9B,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACrE,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;gBACvB,MAAM,eAAe,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;YAC5F,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description ULID (Universally Unique Lexicographically Sortable Identifier) generator.
|
|
3
|
+
* @description Generador de ULID (Identificador Único Lexicográficamente Ordenable).
|
|
4
|
+
*
|
|
5
|
+
* 48 bits timestamp (ms) + 80 bits random, Crockford Base32 encoding.
|
|
6
|
+
* Monotonic within the same millisecond: sequential calls in the same ms produce incrementing IDs.
|
|
7
|
+
*
|
|
8
|
+
* Monotónico dentro del mismo milisegundo: llamadas secuenciales en el mismo ms producen IDs incrementales.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ulid(): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description ULID (Universally Unique Lexicographically Sortable Identifier) generator.
|
|
3
|
+
* @description Generador de ULID (Identificador Único Lexicográficamente Ordenable).
|
|
4
|
+
*
|
|
5
|
+
* 48 bits timestamp (ms) + 80 bits random, Crockford Base32 encoding.
|
|
6
|
+
* Monotonic within the same millisecond: sequential calls in the same ms produce incrementing IDs.
|
|
7
|
+
*
|
|
8
|
+
* Monotónico dentro del mismo milisegundo: llamadas secuenciales en el mismo ms producen IDs incrementales.
|
|
9
|
+
*/
|
|
10
|
+
const CHARS = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
11
|
+
let last_time = 0;
|
|
12
|
+
let last_random_hi = 0;
|
|
13
|
+
let last_random_lo = 0;
|
|
14
|
+
function encode_time(time, len) {
|
|
15
|
+
let str = '';
|
|
16
|
+
for (let i = len; i > 0; i--) {
|
|
17
|
+
str = CHARS[time % 32] + str;
|
|
18
|
+
time = Math.floor(time / 32);
|
|
19
|
+
}
|
|
20
|
+
return str;
|
|
21
|
+
}
|
|
22
|
+
function encode_random() {
|
|
23
|
+
let str = '';
|
|
24
|
+
let hi = last_random_hi;
|
|
25
|
+
let lo = last_random_lo;
|
|
26
|
+
for (let i = 0; i < 8; i++) {
|
|
27
|
+
str = CHARS[lo % 32] + str;
|
|
28
|
+
lo = Math.floor(lo / 32);
|
|
29
|
+
}
|
|
30
|
+
for (let i = 0; i < 8; i++) {
|
|
31
|
+
str = CHARS[hi % 32] + str;
|
|
32
|
+
hi = Math.floor(hi / 32);
|
|
33
|
+
}
|
|
34
|
+
return str;
|
|
35
|
+
}
|
|
36
|
+
export function ulid() {
|
|
37
|
+
let now = Date.now();
|
|
38
|
+
if (now === last_time) {
|
|
39
|
+
last_random_lo++;
|
|
40
|
+
if (last_random_lo > 0xFFFFFFFFFF) {
|
|
41
|
+
last_random_lo = 0;
|
|
42
|
+
last_random_hi++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
last_time = now;
|
|
47
|
+
last_random_hi = Math.floor(Math.random() * 0xFFFFFFFFFF);
|
|
48
|
+
last_random_lo = Math.floor(Math.random() * 0xFFFFFFFFFF);
|
|
49
|
+
}
|
|
50
|
+
return encode_time(now, 10) + encode_random();
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=ulid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ulid.js","sourceRoot":"","sources":["../../../src/utils/ulid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,KAAK,GAAG,kCAAkC,CAAC;AAEjD,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,IAAI,cAAc,GAAG,CAAC,CAAC;AACvB,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB,SAAS,WAAW,CAAC,IAAY,EAAE,GAAW;IAC5C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,GAAG,GAAG,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC;QAC7B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,aAAa;IACpB,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,EAAE,GAAG,cAAc,CAAC;IACxB,IAAI,EAAE,GAAG,cAAc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community@arcaelas.com",
|
|
4
4
|
"name": "Arcaelas Insiders",
|
|
5
5
|
"url": "https://github.com/arcaelas"
|
|
6
6
|
},
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"pluralize": "^8.0.0",
|
|
16
16
|
"uuid": "^11.1.0"
|
|
17
17
|
},
|
|
18
|
+
"description": "Modern decorator-first ORM for AWS DynamoDB with TypeScript support. Type-safe models, relationships, validations, and transactions.",
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"@eslint/js": "^9.39.1",
|
|
20
21
|
"@types/node": "^24.0.6",
|
|
@@ -24,13 +25,31 @@
|
|
|
24
25
|
"typescript": "^5.8.3",
|
|
25
26
|
"typescript-eslint": "^8.49.0"
|
|
26
27
|
},
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": "./build/esm/index.js",
|
|
31
|
+
"require": "./build/cjs/index.js",
|
|
32
|
+
"types": "./build/esm/index.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
27
35
|
"files": [
|
|
28
|
-
"
|
|
29
|
-
"src/**/*.d.ts"
|
|
36
|
+
"build"
|
|
30
37
|
],
|
|
31
38
|
"homepage": "https://github.com/arcaelas/dynamite",
|
|
39
|
+
"keywords": [
|
|
40
|
+
"dynamodb",
|
|
41
|
+
"orm",
|
|
42
|
+
"aws",
|
|
43
|
+
"dynamodb-orm",
|
|
44
|
+
"typescript",
|
|
45
|
+
"decorators",
|
|
46
|
+
"arcaelas",
|
|
47
|
+
"arcaelas insiders",
|
|
48
|
+
"arcaelas-insiders"
|
|
49
|
+
],
|
|
32
50
|
"license": "ISC",
|
|
33
|
-
"main": "
|
|
51
|
+
"main": "./build/cjs/index.js",
|
|
52
|
+
"module": "./build/esm/index.js",
|
|
34
53
|
"name": "@arcaelas/dynamite",
|
|
35
54
|
"publishConfig": {
|
|
36
55
|
"access": "public",
|
|
@@ -41,11 +60,14 @@
|
|
|
41
60
|
"url": "https://github.com/arcaelas/dynamite.git"
|
|
42
61
|
},
|
|
43
62
|
"scripts": {
|
|
44
|
-
"build": "
|
|
63
|
+
"build": "yarn build:esm && yarn build:cjs",
|
|
64
|
+
"build:cjs": "tsc --module commonjs --moduleResolution node --outDir build/cjs && tsc-alias --outDir build/cjs && echo '{\"type\":\"commonjs\"}' > build/cjs/package.json",
|
|
65
|
+
"build:esm": "tsc --module ESNext --moduleResolution bundler --outDir build/esm && tsc-alias --resolve-full-paths --outDir build/esm && echo '{\"type\":\"module\"}' > build/esm/package.json",
|
|
45
66
|
"docs": "mkdocs gh-deploy --force",
|
|
46
|
-
"
|
|
47
|
-
"prepublishOnly": "yarn build",
|
|
48
|
-
"
|
|
67
|
+
"lint": "eslint src/ --fix",
|
|
68
|
+
"prepublishOnly": "rm -rf build && npm version minor && yarn build",
|
|
69
|
+
"release": "npm publish --access public"
|
|
49
70
|
},
|
|
50
|
-
"
|
|
71
|
+
"types": "./build/esm/index.d.ts",
|
|
72
|
+
"version": "3.1.0"
|
|
51
73
|
}
|
package/src/core/client.js
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file client.ts
|
|
4
|
-
* @description Centralized Dynamite client with multi-client support and table sync
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.TransactionContext = exports.requireClient = exports.hasGlobalClient = exports.getGlobalClient = exports.setGlobalClient = exports.Dynamite = void 0;
|
|
43
|
-
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
44
|
-
const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
|
|
45
|
-
const decorator_1 = require("./decorator");
|
|
46
|
-
/**
|
|
47
|
-
* Centralized Dynamite client for managing DynamoDB connections and table synchronization
|
|
48
|
-
*/
|
|
49
|
-
class Dynamite {
|
|
50
|
-
/**
|
|
51
|
-
* Initialize Dynamite client with configuration
|
|
52
|
-
* @param config Dynamite client configuration
|
|
53
|
-
*/
|
|
54
|
-
constructor(config) {
|
|
55
|
-
this.connected = false;
|
|
56
|
-
this.synced = false;
|
|
57
|
-
const { tables, ...options } = config;
|
|
58
|
-
this.client = new client_dynamodb_1.DynamoDBClient({
|
|
59
|
-
...options,
|
|
60
|
-
});
|
|
61
|
-
this.tables = tables;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Connect client and synchronize all declared tables and their GSIs (upsert pattern)
|
|
65
|
-
*/
|
|
66
|
-
async connect() {
|
|
67
|
-
if (this.synced && this.connected)
|
|
68
|
-
return;
|
|
69
|
-
// Set global client for Table operations
|
|
70
|
-
(0, exports.setGlobalClient)(this.client);
|
|
71
|
-
this.connected = true;
|
|
72
|
-
// Crear tablas principales con GSIs
|
|
73
|
-
await Promise.all(this.tables.map((table) => this.createTableWithGSI(table)));
|
|
74
|
-
// Crear pivot tables para relaciones ManyToMany
|
|
75
|
-
await this.createPivotTables();
|
|
76
|
-
this.synced = true;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Auto-crear pivot tables para relaciones ManyToMany
|
|
80
|
-
*/
|
|
81
|
-
async createPivotTables() {
|
|
82
|
-
const pivot_tables = new Map();
|
|
83
|
-
// Recolectar nombres de pivot tables con metadata
|
|
84
|
-
for (const table_class of this.tables) {
|
|
85
|
-
const schema = table_class[decorator_1.SCHEMA];
|
|
86
|
-
if (!schema)
|
|
87
|
-
continue;
|
|
88
|
-
for (const col_name in schema.columns) {
|
|
89
|
-
const col = schema.columns[col_name];
|
|
90
|
-
const relation = col.store?.relation;
|
|
91
|
-
if (relation?.type === "ManyToMany" && relation.pivotTable) {
|
|
92
|
-
pivot_tables.set(relation.pivotTable, {
|
|
93
|
-
foreignKey: relation.foreignKey || "source_id",
|
|
94
|
-
relatedKey: relation.relatedKey || "target_id",
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// Crear cada pivot table con GSIs usando los nombres de columna correctos
|
|
100
|
-
const { CreateTableCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-dynamodb")));
|
|
101
|
-
await Promise.all(Array.from(pivot_tables.entries()).map(async ([pivot_name, metadata]) => {
|
|
102
|
-
const { foreignKey, relatedKey } = metadata;
|
|
103
|
-
try {
|
|
104
|
-
await this.client.send(new CreateTableCommand({
|
|
105
|
-
TableName: pivot_name,
|
|
106
|
-
KeySchema: [{ AttributeName: "id", KeyType: "HASH" }],
|
|
107
|
-
AttributeDefinitions: [
|
|
108
|
-
{ AttributeName: "id", AttributeType: "S" },
|
|
109
|
-
{ AttributeName: foreignKey, AttributeType: "S" },
|
|
110
|
-
{ AttributeName: relatedKey, AttributeType: "S" },
|
|
111
|
-
],
|
|
112
|
-
GlobalSecondaryIndexes: [
|
|
113
|
-
{
|
|
114
|
-
IndexName: `${foreignKey}_index`,
|
|
115
|
-
KeySchema: [{ AttributeName: foreignKey, KeyType: "HASH" }],
|
|
116
|
-
Projection: { ProjectionType: "ALL" },
|
|
117
|
-
ProvisionedThroughput: {
|
|
118
|
-
ReadCapacityUnits: 5,
|
|
119
|
-
WriteCapacityUnits: 5,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
IndexName: `${relatedKey}_index`,
|
|
124
|
-
KeySchema: [{ AttributeName: relatedKey, KeyType: "HASH" }],
|
|
125
|
-
Projection: { ProjectionType: "ALL" },
|
|
126
|
-
ProvisionedThroughput: {
|
|
127
|
-
ReadCapacityUnits: 5,
|
|
128
|
-
WriteCapacityUnits: 5,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
ProvisionedThroughput: {
|
|
133
|
-
ReadCapacityUnits: 5,
|
|
134
|
-
WriteCapacityUnits: 5,
|
|
135
|
-
},
|
|
136
|
-
}));
|
|
137
|
-
console.log(`✓ Pivot table '${pivot_name}' created`);
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
if (error.name === "ResourceInUseException") {
|
|
141
|
-
console.log(`✓ Pivot table '${pivot_name}' already exists`);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
throw error;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Ejecutar operaciones en una transacción atómica.
|
|
151
|
-
* Si cualquier operación falla, todas se revierten automáticamente.
|
|
152
|
-
*
|
|
153
|
-
* @param callback Función que recibe el contexto de transacción
|
|
154
|
-
* @returns Resultado del callback
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* await dynamite.tx(async (tx) => {
|
|
158
|
-
* const user = await User.create({ name: "Juan" }, tx);
|
|
159
|
-
* await Order.create({ user_id: user.id, total: 100 }, tx);
|
|
160
|
-
* });
|
|
161
|
-
*/
|
|
162
|
-
async tx(callback) {
|
|
163
|
-
const ctx = new TransactionContext(this.client);
|
|
164
|
-
const result = await callback(ctx);
|
|
165
|
-
await ctx.commit();
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Create table with automatic GSI detection and creation
|
|
170
|
-
* @param ctor Table class constructor
|
|
171
|
-
*/
|
|
172
|
-
async createTableWithGSI(ctor) {
|
|
173
|
-
const meta = ctor[decorator_1.SCHEMA];
|
|
174
|
-
if (!meta)
|
|
175
|
-
throw new Error(`Class ${ctor.name} not registered. Use decorators.`);
|
|
176
|
-
const cols = Object.values(meta.columns);
|
|
177
|
-
const pk = cols.find((c) => c.store?.index);
|
|
178
|
-
if (!pk)
|
|
179
|
-
throw new Error(`PartitionKey missing in ${ctor.name}`);
|
|
180
|
-
const sk = cols.find((c) => c.store?.indexSort);
|
|
181
|
-
const attr = new Map();
|
|
182
|
-
attr.set(pk.name || "id", "S");
|
|
183
|
-
if (sk)
|
|
184
|
-
attr.set(sk.name || "id", "S");
|
|
185
|
-
// Temporalmente deshabilitamos la creación automática de GSI hasta implementar relaciones
|
|
186
|
-
const gsiDefinitions = [];
|
|
187
|
-
const schema = [{ AttributeName: pk.name || "id", KeyType: "HASH" }];
|
|
188
|
-
if (sk && sk.name !== pk.name)
|
|
189
|
-
schema.push({
|
|
190
|
-
AttributeName: sk.name || "id",
|
|
191
|
-
KeyType: "RANGE",
|
|
192
|
-
});
|
|
193
|
-
try {
|
|
194
|
-
await this.client.send(new client_dynamodb_1.CreateTableCommand({
|
|
195
|
-
TableName: meta.name,
|
|
196
|
-
BillingMode: "PAY_PER_REQUEST",
|
|
197
|
-
AttributeDefinitions: [...attr].map(([AttributeName, AttributeType]) => ({
|
|
198
|
-
AttributeName,
|
|
199
|
-
AttributeType,
|
|
200
|
-
})),
|
|
201
|
-
KeySchema: schema,
|
|
202
|
-
...(gsiDefinitions.length > 0 && {
|
|
203
|
-
GlobalSecondaryIndexes: gsiDefinitions,
|
|
204
|
-
}),
|
|
205
|
-
}));
|
|
206
|
-
}
|
|
207
|
-
catch (error) {
|
|
208
|
-
if (error.name !== "ResourceInUseException")
|
|
209
|
-
throw error;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
exports.Dynamite = Dynamite;
|
|
214
|
-
let globalClient;
|
|
215
|
-
/**
|
|
216
|
-
* Set global client for Table class operations
|
|
217
|
-
* @param client DynamoDB client instance
|
|
218
|
-
*/
|
|
219
|
-
const setGlobalClient = (client) => {
|
|
220
|
-
globalClient = client;
|
|
221
|
-
};
|
|
222
|
-
exports.setGlobalClient = setGlobalClient;
|
|
223
|
-
/**
|
|
224
|
-
* Get global client for Table class operations
|
|
225
|
-
*/
|
|
226
|
-
const getGlobalClient = () => {
|
|
227
|
-
if (!globalClient)
|
|
228
|
-
throw new Error("No global DynamoDB client set. Call setGlobalClient() first.");
|
|
229
|
-
return globalClient;
|
|
230
|
-
};
|
|
231
|
-
exports.getGlobalClient = getGlobalClient;
|
|
232
|
-
/**
|
|
233
|
-
* Check if global client is available
|
|
234
|
-
*/
|
|
235
|
-
const hasGlobalClient = () => {
|
|
236
|
-
return globalClient !== undefined;
|
|
237
|
-
};
|
|
238
|
-
exports.hasGlobalClient = hasGlobalClient;
|
|
239
|
-
/**
|
|
240
|
-
* Require global client for Table operations (throws if not available)
|
|
241
|
-
*/
|
|
242
|
-
const requireClient = () => {
|
|
243
|
-
if (!globalClient) {
|
|
244
|
-
throw new Error("DynamoDB client no configurado. Use Dynamite.connect() primero.");
|
|
245
|
-
}
|
|
246
|
-
return globalClient;
|
|
247
|
-
};
|
|
248
|
-
exports.requireClient = requireClient;
|
|
249
|
-
/**
|
|
250
|
-
* Contexto de transacción para agrupar operaciones atómicas.
|
|
251
|
-
* Máximo 25 operaciones por transacción (límite DynamoDB).
|
|
252
|
-
*/
|
|
253
|
-
class TransactionContext {
|
|
254
|
-
constructor(client) {
|
|
255
|
-
this.operations = [];
|
|
256
|
-
this.client = client;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Agregar operación Put a la transacción
|
|
260
|
-
*/
|
|
261
|
-
addPut(table_name, item) {
|
|
262
|
-
this.operations.push({
|
|
263
|
-
Put: {
|
|
264
|
-
TableName: table_name,
|
|
265
|
-
Item: (0, util_dynamodb_1.marshall)(item, { removeUndefinedValues: true }),
|
|
266
|
-
},
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Agregar operación Delete a la transacción
|
|
271
|
-
*/
|
|
272
|
-
addDelete(table_name, key) {
|
|
273
|
-
this.operations.push({
|
|
274
|
-
Delete: {
|
|
275
|
-
TableName: table_name,
|
|
276
|
-
Key: (0, util_dynamodb_1.marshall)(key),
|
|
277
|
-
},
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Confirmar todas las operaciones de la transacción.
|
|
282
|
-
* Si alguna falla, todas se revierten.
|
|
283
|
-
*/
|
|
284
|
-
async commit() {
|
|
285
|
-
if (this.operations.length === 0)
|
|
286
|
-
return;
|
|
287
|
-
if (this.operations.length > 25) {
|
|
288
|
-
throw new Error(`Transacción excede el límite de 25 operaciones (tiene ${this.operations.length})`);
|
|
289
|
-
}
|
|
290
|
-
await this.client.send(new client_dynamodb_1.TransactWriteItemsCommand({
|
|
291
|
-
TransactItems: this.operations,
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
exports.TransactionContext = TransactionContext;
|
|
296
|
-
//# sourceMappingURL=client.js.map
|
package/src/core/decorator.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file decorator.ts
|
|
3
|
-
* @description Sistema de decoradores minimalista con Symbol storage
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-28
|
|
6
|
-
*/
|
|
7
|
-
export declare const SCHEMA: unique symbol;
|
|
8
|
-
/**
|
|
9
|
-
* @description Factory para crear decoradores con soporte de argumentos y composición
|
|
10
|
-
* @param callback Función que recibe (schema, col, params) para configurar la columna
|
|
11
|
-
* @returns Función que acepta argumentos y retorna PropertyDecorator
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const Default = decorator((schema, col, params) => {
|
|
15
|
-
* const fallback = params[0];
|
|
16
|
-
* col.get.push((value) => value ?? fallback());
|
|
17
|
-
* });
|
|
18
|
-
* // Uso: @Default(uuid)
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function decorator(callback: (schema: any, col: any, params: any[]) => void): (...params: any[]) => (target: any, propertyKey: string | symbol) => void;
|
|
22
|
-
/**
|
|
23
|
-
* @description Factory para decoradores de relación
|
|
24
|
-
* @param relation_type Tipo de relación ("hasMany", "hasOne", "belongsTo")
|
|
25
|
-
* @param RelatedTable Clase de la tabla relacionada
|
|
26
|
-
* @param options Opciones de relación (foreignKey, localKey)
|
|
27
|
-
* @returns PropertyDecorator
|
|
28
|
-
*/
|
|
29
|
-
export declare function relationDecorator(relation_type: string, RelatedTable: any, options?: any): (target: any, propertyKey: string | symbol) => void;
|
package/src/core/decorator.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file decorator.ts
|
|
4
|
-
* @description Sistema de decoradores minimalista con Symbol storage
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-28
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.SCHEMA = void 0;
|
|
10
|
-
exports.decorator = decorator;
|
|
11
|
-
exports.relationDecorator = relationDecorator;
|
|
12
|
-
// Symbols para autocontención (exportados desde table.ts pero también aquí compatibilidad)
|
|
13
|
-
exports.SCHEMA = Symbol('dynamite:schema');
|
|
14
|
-
// Helper simple para snake_case plural
|
|
15
|
-
function toSnakePlural(str) {
|
|
16
|
-
const snake = str
|
|
17
|
-
.replace(/([A-Z])/g, "_$1")
|
|
18
|
-
.toLowerCase()
|
|
19
|
-
.replace(/^_/, "");
|
|
20
|
-
return snake.endsWith("s") ? snake : snake + "s";
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @description Factory para crear decoradores con soporte de argumentos y composición
|
|
24
|
-
* @param callback Función que recibe (schema, col, params) para configurar la columna
|
|
25
|
-
* @returns Función que acepta argumentos y retorna PropertyDecorator
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const Default = decorator((schema, col, params) => {
|
|
29
|
-
* const fallback = params[0];
|
|
30
|
-
* col.get.push((value) => value ?? fallback());
|
|
31
|
-
* });
|
|
32
|
-
* // Uso: @Default(uuid)
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
function decorator(callback) {
|
|
36
|
-
return (...params) => {
|
|
37
|
-
return function (target, propertyKey) {
|
|
38
|
-
const table_class = target.constructor;
|
|
39
|
-
const column_name = String(propertyKey);
|
|
40
|
-
// Inicializar SCHEMA SI NO TIENE UNO PROPIO (no heredado)
|
|
41
|
-
if (!Object.prototype.hasOwnProperty.call(table_class, exports.SCHEMA)) {
|
|
42
|
-
table_class[exports.SCHEMA] = {
|
|
43
|
-
name: toSnakePlural(table_class.name),
|
|
44
|
-
primary_key: 'id',
|
|
45
|
-
columns: {}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
// Crear columna si no existe
|
|
49
|
-
if (!table_class[exports.SCHEMA].columns[column_name]) {
|
|
50
|
-
table_class[exports.SCHEMA].columns[column_name] = {
|
|
51
|
-
name: column_name,
|
|
52
|
-
get: [],
|
|
53
|
-
set: [],
|
|
54
|
-
store: {}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const col = table_class[exports.SCHEMA].columns[column_name];
|
|
58
|
-
// Ejecutar callback con (schema, col, params)
|
|
59
|
-
callback(table_class, col, params);
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @description Factory para decoradores de relación
|
|
65
|
-
* @param relation_type Tipo de relación ("hasMany", "hasOne", "belongsTo")
|
|
66
|
-
* @param RelatedTable Clase de la tabla relacionada
|
|
67
|
-
* @param options Opciones de relación (foreignKey, localKey)
|
|
68
|
-
* @returns PropertyDecorator
|
|
69
|
-
*/
|
|
70
|
-
function relationDecorator(relation_type, RelatedTable, options = {}) {
|
|
71
|
-
return function (target, propertyKey) {
|
|
72
|
-
const table_class = target.constructor;
|
|
73
|
-
const column_name = String(propertyKey);
|
|
74
|
-
// Inicializar SCHEMA SI NO TIENE UNO PROPIO (no heredado)
|
|
75
|
-
if (!Object.prototype.hasOwnProperty.call(table_class, exports.SCHEMA)) {
|
|
76
|
-
table_class[exports.SCHEMA] = {
|
|
77
|
-
name: toSnakePlural(table_class.name),
|
|
78
|
-
primary_key: 'id',
|
|
79
|
-
columns: {}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
// **Validación: No sobreescribir columnas existentes**
|
|
83
|
-
if (table_class[exports.SCHEMA].columns[column_name]) {
|
|
84
|
-
throw new Error(`Column '${column_name}' already exists. Cannot apply relation decorator.`);
|
|
85
|
-
}
|
|
86
|
-
// Crear columna virtual para relación
|
|
87
|
-
table_class[exports.SCHEMA].columns[column_name] = {
|
|
88
|
-
name: column_name,
|
|
89
|
-
get: [],
|
|
90
|
-
set: [],
|
|
91
|
-
store: {
|
|
92
|
-
relation: {
|
|
93
|
-
type: relation_type,
|
|
94
|
-
target: RelatedTable,
|
|
95
|
-
foreignKey: options.foreignKey,
|
|
96
|
-
localKey: options.localKey,
|
|
97
|
-
nullable: options.nullable
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=decorator.js.map
|
package/src/core/table.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { InferAttributes, QueryOperator, WhereOptions } from "../@types/index";
|
|
2
|
-
import { TransactionContext } from "./client";
|
|
3
|
-
import { SCHEMA } from "./decorator";
|
|
4
|
-
type SimpleWhereOptions<M> = {
|
|
5
|
-
order?: "ASC" | "DESC" | {
|
|
6
|
-
[key: string]: "ASC" | "DESC";
|
|
7
|
-
};
|
|
8
|
-
offset?: number;
|
|
9
|
-
skip?: number;
|
|
10
|
-
limit?: number;
|
|
11
|
-
attributes?: (keyof InferAttributes<M>)[];
|
|
12
|
-
include?: NonNullable<WhereOptions<M>["include"]>;
|
|
13
|
-
_includeTrashed?: boolean;
|
|
14
|
-
};
|
|
15
|
-
type Noop = (...args: any) => any;
|
|
16
|
-
interface Schema {
|
|
17
|
-
name: string;
|
|
18
|
-
primary_key: string;
|
|
19
|
-
columns: {
|
|
20
|
-
[K: string]: {
|
|
21
|
-
get: Noop;
|
|
22
|
-
set: Noop;
|
|
23
|
-
store: {
|
|
24
|
-
[K: string]: any;
|
|
25
|
-
relation: {
|
|
26
|
-
type: "HasMany" | "HasOne" | "BelognsTo" | "ManyToMany";
|
|
27
|
-
local: string;
|
|
28
|
-
foreign: string;
|
|
29
|
-
pivot?: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export default class Table<T = any> {
|
|
36
|
-
static [SCHEMA]: Schema;
|
|
37
|
-
private readonly _relationCache;
|
|
38
|
-
constructor(props?: Partial<T>);
|
|
39
|
-
toJSON(): Record<string, unknown>;
|
|
40
|
-
/**
|
|
41
|
-
* @description Mapea nombres de propiedades TypeScript a nombres de columnas de DB
|
|
42
|
-
* @param data Objeto con propiedades TypeScript
|
|
43
|
-
* @returns Objeto con nombres de columnas de DB
|
|
44
|
-
*/
|
|
45
|
-
private _mapPropertiesToDB;
|
|
46
|
-
/**
|
|
47
|
-
* @description Mapea nombres de columnas de DB a nombres de propiedades TypeScript
|
|
48
|
-
* @param data Objeto con nombres de columnas de DB
|
|
49
|
-
* @returns Objeto con propiedades TypeScript
|
|
50
|
-
*/
|
|
51
|
-
private static _mapDBToProperties;
|
|
52
|
-
/**
|
|
53
|
-
* @description Convierte la instancia a un payload listo para DynamoDB
|
|
54
|
-
* @returns Objeto con nombres de columnas de DB y valores apropiados
|
|
55
|
-
*/
|
|
56
|
-
private _toDBPayload;
|
|
57
|
-
toString(): string;
|
|
58
|
-
save(): Promise<boolean>;
|
|
59
|
-
update(data: Partial<InferAttributes<T>>): Promise<boolean>;
|
|
60
|
-
destroy(): Promise<null>;
|
|
61
|
-
forceDestroy(): Promise<null>;
|
|
62
|
-
attach<R>(RelatedModel: new () => R, related_id: string, pivot_data?: Record<string, any>): Promise<void>;
|
|
63
|
-
detach<R>(RelatedModel: new () => R, related_id: string): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Sincronizar relación ManyToMany reemplazando todas las relaciones existentes
|
|
66
|
-
* @param RelatedModel Modelo relacionado
|
|
67
|
-
* @param related_ids Array de IDs a sincronizar
|
|
68
|
-
*/
|
|
69
|
-
sync<R>(RelatedModel: new () => R, related_ids: string[]): Promise<void>;
|
|
70
|
-
static create<M extends Table>(this: new (data: any) => M, data: Partial<InferAttributes<M>>, tx?: TransactionContext): Promise<M>;
|
|
71
|
-
static update<M extends Table>(this: new (data: any) => M, updates: Partial<InferAttributes<M>>, filters: Partial<InferAttributes<M>>, tx?: TransactionContext): Promise<number>;
|
|
72
|
-
static delete<M extends Table>(this: new (data: any) => M, filters: Partial<InferAttributes<M>>, tx?: TransactionContext): Promise<number>;
|
|
73
|
-
static where<M extends Table>(this: new (props?: any) => M, key: keyof InferAttributes<M>, value: any, options?: SimpleWhereOptions<M>): Promise<M[]>;
|
|
74
|
-
static where<M extends Table>(this: new (props?: any) => M, key: keyof InferAttributes<M>, operator: QueryOperator, value: any, options?: SimpleWhereOptions<M>): Promise<M[]>;
|
|
75
|
-
static where<M extends Table>(this: new (props?: any) => M, query: object, options?: SimpleWhereOptions<M>): Promise<M[]>;
|
|
76
|
-
static first<M extends Table>(this: new (props?: any) => M, field_or_filters: any, operator_or_value?: any, value_or_options?: any): Promise<M | undefined>;
|
|
77
|
-
static last<M extends Table>(this: new (props?: any) => M, field_or_filters?: any, operator_or_value?: any): Promise<M | undefined>;
|
|
78
|
-
static withTrashed<M extends Table>(this: new (props?: any) => M, filters?: any, options?: WhereOptions<M>): Promise<M[]>;
|
|
79
|
-
static onlyTrashed<M extends Table>(this: new (props?: any) => M, filters?: any, options?: WhereOptions<M>): Promise<M[]>;
|
|
80
|
-
}
|
|
81
|
-
export {};
|