alepha 0.15.0 → 0.15.1
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 +43 -98
- package/dist/api/audits/index.d.ts +240 -240
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +2 -2
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +185 -185
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +2 -2
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +245 -245
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/notifications/index.browser.js +4 -4
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +74 -74
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +4 -4
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.d.ts +221 -221
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/users/index.d.ts +1632 -1631
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +26 -34
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +132 -132
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/batch/index.d.ts +122 -122
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/bucket/index.d.ts +163 -163
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/cache/core/index.d.ts +46 -46
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js +2 -2
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/cli/index.d.ts +5933 -201
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +609 -169
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +296 -296
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +19 -19
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +268 -79
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +768 -694
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +268 -79
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +268 -79
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +44 -44
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/email/index.d.ts +25 -25
- package/dist/email/index.d.ts.map +1 -1
- package/dist/fake/index.d.ts +5409 -5409
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js +22 -22
- package/dist/fake/index.js.map +1 -1
- package/dist/file/index.d.ts +435 -435
- package/dist/file/index.d.ts.map +1 -1
- package/dist/lock/core/index.d.ts +208 -208
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts +24 -24
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +1 -5
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +216 -198
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +28 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.browser.js +9 -9
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +83 -76
- package/dist/orm/index.bun.js.map +1 -1
- package/dist/orm/index.d.ts +961 -960
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +88 -81
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +244 -244
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/redis/index.d.ts +105 -105
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/retry/index.d.ts +69 -69
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +108 -26
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +393 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +532 -209
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1422 -11
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +1296 -271
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +1249 -18
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +56 -56
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/compress/index.d.ts +3 -3
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/cookies/index.d.ts +6 -6
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/core/index.d.ts +196 -186
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +43 -27
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -11
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/helmet/index.d.ts +2 -2
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/links/index.browser.js +9 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +83 -83
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +13 -5
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +514 -1
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js +4462 -4
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/multipart/index.d.ts +6 -6
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/proxy/index.d.ts +102 -102
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.d.ts +16 -16
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/static/index.d.ts +44 -44
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/swagger/index.d.ts +47 -47
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/sms/index.d.ts +11 -11
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +3 -3
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +71 -71
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/thread/index.js +2 -2
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/core/index.d.ts +318 -318
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/redis/index.d.ts +6 -6
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/vite/index.d.ts +2324 -1719
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +123 -475
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +3 -3
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +275 -275
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +3 -3
- package/dist/websocket/index.js.map +1 -1
- package/package.json +9 -9
- package/src/api/users/services/SessionService.ts +0 -10
- package/src/cli/apps/AlephaCli.ts +2 -2
- package/src/cli/apps/AlephaPackageBuilderCli.ts +9 -1
- package/src/cli/assets/apiHelloControllerTs.ts +2 -1
- package/src/cli/assets/biomeJson.ts +2 -1
- package/src/cli/assets/claudeMd.ts +9 -4
- package/src/cli/assets/dummySpecTs.ts +2 -1
- package/src/cli/assets/editorconfig.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +2 -1
- package/src/cli/assets/mainCss.ts +24 -0
- package/src/cli/assets/tsconfigJson.ts +2 -1
- package/src/cli/assets/webAppRouterTs.ts +2 -1
- package/src/cli/assets/webHelloComponentTsx.ts +6 -2
- package/src/cli/atoms/appEntryOptions.ts +13 -0
- package/src/cli/atoms/buildOptions.ts +1 -1
- package/src/cli/atoms/changelogOptions.ts +1 -1
- package/src/cli/commands/build.ts +63 -47
- package/src/cli/commands/dev.ts +16 -33
- package/src/cli/commands/gen/env.ts +1 -1
- package/src/cli/commands/init.ts +17 -8
- package/src/cli/commands/lint.ts +1 -1
- package/src/cli/defineConfig.ts +9 -0
- package/src/cli/index.ts +2 -1
- package/src/cli/providers/AppEntryProvider.ts +131 -0
- package/src/cli/providers/ViteBuildProvider.ts +82 -0
- package/src/cli/providers/ViteDevServerProvider.ts +350 -0
- package/src/cli/providers/ViteTemplateProvider.ts +27 -0
- package/src/cli/services/AlephaCliUtils.ts +33 -2
- package/src/cli/services/PackageManagerUtils.ts +13 -6
- package/src/cli/services/ProjectScaffolder.ts +72 -49
- package/src/core/Alepha.ts +2 -8
- package/src/core/primitives/$module.ts +12 -0
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +257 -0
- package/src/core/providers/KeylessJsonSchemaCodec.ts +396 -14
- package/src/core/providers/SchemaValidator.spec.ts +236 -0
- package/src/logger/providers/PrettyFormatterProvider.ts +0 -9
- package/src/mcp/errors/McpError.ts +30 -0
- package/src/mcp/index.ts +3 -0
- package/src/mcp/transports/SseMcpTransport.ts +16 -6
- package/src/orm/providers/DrizzleKitProvider.ts +3 -5
- package/src/orm/services/Repository.ts +11 -0
- package/src/server/core/index.ts +1 -1
- package/src/server/core/providers/BunHttpServerProvider.ts +1 -1
- package/src/server/core/providers/NodeHttpServerProvider.spec.ts +125 -0
- package/src/server/core/providers/NodeHttpServerProvider.ts +71 -22
- package/src/server/core/providers/ServerLoggerProvider.ts +2 -2
- package/src/server/core/providers/ServerProvider.ts +9 -12
- package/src/server/links/atoms/apiLinksAtom.ts +7 -0
- package/src/server/links/index.browser.ts +2 -0
- package/src/server/links/index.ts +2 -0
- package/src/vite/index.ts +3 -2
- package/src/vite/tasks/buildClient.ts +0 -1
- package/src/vite/tasks/buildServer.ts +68 -21
- package/src/vite/tasks/copyAssets.ts +5 -4
- package/src/vite/tasks/generateSitemap.ts +64 -23
- package/src/vite/tasks/index.ts +0 -2
- package/src/vite/tasks/prerenderPages.ts +49 -24
- package/src/cli/assets/indexHtml.ts +0 -15
- package/src/cli/commands/format.ts +0 -23
- package/src/vite/helpers/boot.ts +0 -117
- package/src/vite/plugins/viteAlephaDev.ts +0 -177
- package/src/vite/tasks/devServer.ts +0 -71
- package/src/vite/tasks/runAlepha.ts +0 -270
- /package/dist/orm/{chunk-DtkW-qnP.js → chunk-DH6iiROE.js} +0 -0
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./chunk-
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-DH6iiROE.js";
|
|
2
2
|
import * as alepha34 from "alepha";
|
|
3
3
|
import { Alepha, AlephaError, KIND, Page, Page as Page$1, PageQuery, PageQuery as PageQuery$1, Primitive, Service, Static, StaticEncode, TBigInt, TInteger, TNull, TNumber, TNumberOptions, TObject, TObjectOptions, TOptional, TPage, TSchema, TString, TStringOptions, TUnion, TUnsafe, pageQuerySchema, pageSchema } from "alepha";
|
|
4
4
|
import { DateTime, DateTimeProvider } from "alepha/datetime";
|
|
@@ -6,7 +6,7 @@ import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
|
6
6
|
import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSchema, PgSelectBase, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
7
7
|
import * as drizzle_orm0 from "drizzle-orm";
|
|
8
8
|
import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, sql } from "drizzle-orm";
|
|
9
|
-
import * as
|
|
9
|
+
import * as alepha_logger4 from "alepha/logger";
|
|
10
10
|
import * as alepha_lock0 from "alepha/lock";
|
|
11
11
|
import * as pg$1 from "drizzle-orm/sqlite-core";
|
|
12
12
|
import { SQLiteColumnBuilderBase } from "drizzle-orm/sqlite-core";
|
|
@@ -73,119 +73,119 @@ declare const updateSchema: <T extends TObject>(schema: T) => TObjectUpdate<T>;
|
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
75
75
|
declare const $entity: {
|
|
76
|
-
<TSchema
|
|
76
|
+
<TSchema extends TObject>(options: EntityPrimitiveOptions<TSchema>): EntityPrimitive<TSchema>;
|
|
77
77
|
[KIND]: typeof EntityPrimitive;
|
|
78
78
|
};
|
|
79
79
|
interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
80
80
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
* The database table name that will be created for this entity.
|
|
82
|
+
* If not provided, name will be inferred from the $repository variable name.
|
|
83
|
+
*/
|
|
84
84
|
name: string;
|
|
85
85
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
* TypeBox schema defining the table structure and column types.
|
|
87
|
+
*/
|
|
88
88
|
schema: T;
|
|
89
89
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
* Database indexes to create for query optimization.
|
|
91
|
+
*/
|
|
92
92
|
indexes?: (Keys | {
|
|
93
93
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
* Single column to index.
|
|
95
|
+
*/
|
|
96
96
|
column: Keys;
|
|
97
97
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
99
|
+
*/
|
|
100
100
|
unique?: boolean;
|
|
101
101
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
103
|
+
*/
|
|
104
104
|
name?: string;
|
|
105
105
|
} | {
|
|
106
106
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
* Multiple columns for composite index (order matters for query optimization).
|
|
108
|
+
*/
|
|
109
109
|
columns: Keys[];
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
112
|
+
*/
|
|
113
113
|
unique?: boolean;
|
|
114
114
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
116
|
+
*/
|
|
117
117
|
name?: string;
|
|
118
118
|
})[];
|
|
119
119
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
* Foreign key constraints to maintain referential integrity.
|
|
121
|
+
*/
|
|
122
122
|
foreignKeys?: Array<{
|
|
123
123
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
* Optional name for the foreign key constraint.
|
|
125
|
+
*/
|
|
126
126
|
name?: string;
|
|
127
127
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
* Local columns that reference the foreign table.
|
|
129
|
+
*/
|
|
130
130
|
columns: Array<keyof Static<T>>;
|
|
131
131
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
* Referenced columns in the foreign table.
|
|
133
|
+
* Must be EntityColumn references from other entities.
|
|
134
|
+
*/
|
|
135
135
|
foreignColumns: Array<() => EntityColumn<any>>;
|
|
136
136
|
}>;
|
|
137
137
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
138
|
+
* Additional table constraints for data validation.
|
|
139
|
+
*
|
|
140
|
+
* Constraints enforce business rules at the database level, providing
|
|
141
|
+
* an additional layer of data integrity beyond application validation.
|
|
142
|
+
*
|
|
143
|
+
* **Constraint Types**:
|
|
144
|
+
* - **Unique constraints**: Prevent duplicate values across columns
|
|
145
|
+
* - **Check constraints**: Enforce custom validation rules with SQL expressions
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* constraints: [
|
|
150
|
+
* {
|
|
151
|
+
* name: "unique_user_email",
|
|
152
|
+
* columns: ["email"],
|
|
153
|
+
* unique: true
|
|
154
|
+
* },
|
|
155
|
+
* {
|
|
156
|
+
* name: "valid_age_range",
|
|
157
|
+
* columns: ["age"],
|
|
158
|
+
* check: sql`age >= 0 AND age <= 150`
|
|
159
|
+
* },
|
|
160
|
+
* {
|
|
161
|
+
* name: "unique_user_username_per_tenant",
|
|
162
|
+
* columns: ["tenantId", "username"],
|
|
163
|
+
* unique: true
|
|
164
|
+
* }
|
|
165
|
+
* ]
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
168
|
constraints?: Array<{
|
|
169
169
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
* Columns involved in this constraint.
|
|
171
|
+
*/
|
|
172
172
|
columns: Array<keyof Static<T>>;
|
|
173
173
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
* Optional name for the constraint.
|
|
175
|
+
*/
|
|
176
176
|
name?: string;
|
|
177
177
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
* Whether this is a unique constraint.
|
|
179
|
+
*/
|
|
180
180
|
unique?: boolean | {};
|
|
181
181
|
/**
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
* SQL expression for check constraint validation.
|
|
183
|
+
*/
|
|
184
184
|
check?: SQL;
|
|
185
185
|
}>;
|
|
186
186
|
/**
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
* Advanced Drizzle ORM configuration for complex table setups.
|
|
188
|
+
*/
|
|
189
189
|
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
190
190
|
}
|
|
191
191
|
declare class EntityPrimitive<T extends TObject = TObject> {
|
|
@@ -242,8 +242,8 @@ type PgSymbols = {
|
|
|
242
242
|
[PG_REF]: PgRefOptions;
|
|
243
243
|
[PG_ENUM]: PgEnumOptions;
|
|
244
244
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
* @deprecated Use `PG_IDENTITY` instead.
|
|
246
|
+
*/
|
|
247
247
|
[PG_SERIAL]: {};
|
|
248
248
|
};
|
|
249
249
|
type PgSymbolKeys = keyof PgSymbols;
|
|
@@ -306,416 +306,416 @@ declare class DbEntityNotFoundError extends DbError {
|
|
|
306
306
|
//#region ../../src/orm/interfaces/FilterOperators.d.ts
|
|
307
307
|
interface FilterOperators<TValue> {
|
|
308
308
|
/**
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
309
|
+
* Test that two values are equal.
|
|
310
|
+
*
|
|
311
|
+
* Remember that the SQL standard dictates that
|
|
312
|
+
* two NULL values are not equal, so if you want to test
|
|
313
|
+
* whether a value is null, you may want to use
|
|
314
|
+
* `isNull` instead.
|
|
315
|
+
*
|
|
316
|
+
* ## Examples
|
|
317
|
+
*
|
|
318
|
+
* ```ts
|
|
319
|
+
* // Select cars made by Ford
|
|
320
|
+
* db.select().from(cars)
|
|
321
|
+
* .where(eq(cars.make, 'Ford'))
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @see isNull for a way to test equality to NULL.
|
|
325
|
+
*/
|
|
326
326
|
eq?: TValue;
|
|
327
327
|
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
328
|
+
* Test that two values are not equal.
|
|
329
|
+
*
|
|
330
|
+
* Remember that the SQL standard dictates that
|
|
331
|
+
* two NULL values are not equal, so if you want to test
|
|
332
|
+
* whether a value is not null, you may want to use
|
|
333
|
+
* `isNotNull` instead.
|
|
334
|
+
*
|
|
335
|
+
* ## Examples
|
|
336
|
+
*
|
|
337
|
+
* ```ts
|
|
338
|
+
* // Select cars not made by Ford
|
|
339
|
+
* db.select().from(cars)
|
|
340
|
+
* .where(ne(cars.make, 'Ford'))
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @see isNotNull for a way to test whether a value is not null.
|
|
344
|
+
*/
|
|
345
345
|
ne?: TValue;
|
|
346
346
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
347
|
+
* Test that the first expression passed is greater than
|
|
348
|
+
* the second expression.
|
|
349
|
+
*
|
|
350
|
+
* ## Examples
|
|
351
|
+
*
|
|
352
|
+
* ```ts
|
|
353
|
+
* // Select cars made after 2000.
|
|
354
|
+
* db.select().from(cars)
|
|
355
|
+
* .where(gt(cars.year, 2000))
|
|
356
|
+
* ```
|
|
357
|
+
*
|
|
358
|
+
* @see gte for greater-than-or-equal
|
|
359
|
+
*/
|
|
360
360
|
gt?: TValue;
|
|
361
361
|
/**
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
362
|
+
* Test that the first expression passed is greater than
|
|
363
|
+
* or equal to the second expression. Use `gt` to
|
|
364
|
+
* test whether an expression is strictly greater
|
|
365
|
+
* than another.
|
|
366
|
+
*
|
|
367
|
+
* ## Examples
|
|
368
|
+
*
|
|
369
|
+
* ```ts
|
|
370
|
+
* // Select cars made on or after 2000.
|
|
371
|
+
* db.select().from(cars)
|
|
372
|
+
* .where(gte(cars.year, 2000))
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @see gt for a strictly greater-than condition
|
|
376
|
+
*/
|
|
377
377
|
gte?: TValue;
|
|
378
378
|
/**
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
379
|
+
* Test that the first expression passed is less than
|
|
380
|
+
* the second expression.
|
|
381
|
+
*
|
|
382
|
+
* ## Examples
|
|
383
|
+
*
|
|
384
|
+
* ```ts
|
|
385
|
+
* // Select cars made before 2000.
|
|
386
|
+
* db.select().from(cars)
|
|
387
|
+
* .where(lt(cars.year, 2000))
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* @see lte for greater-than-or-equal
|
|
391
|
+
*/
|
|
392
392
|
lt?: TValue;
|
|
393
393
|
/**
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
394
|
+
* Test that the first expression passed is less than
|
|
395
|
+
* or equal to the second expression.
|
|
396
|
+
*
|
|
397
|
+
* ## Examples
|
|
398
|
+
*
|
|
399
|
+
* ```ts
|
|
400
|
+
* // Select cars made before 2000.
|
|
401
|
+
* db.select().from(cars)
|
|
402
|
+
* .where(lte(cars.year, 2000))
|
|
403
|
+
* ```
|
|
404
|
+
*
|
|
405
|
+
* @see lt for a strictly less-than condition
|
|
406
|
+
*/
|
|
407
407
|
lte?: TValue;
|
|
408
408
|
/**
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
409
|
+
* Test whether the first parameter, a column or expression,
|
|
410
|
+
* has a value from a list passed as the second argument.
|
|
411
|
+
*
|
|
412
|
+
* ## Throws
|
|
413
|
+
*
|
|
414
|
+
* The argument passed in the second array can't be empty:
|
|
415
|
+
* if an empty is provided, this method will throw.
|
|
416
|
+
*
|
|
417
|
+
* ## Examples
|
|
418
|
+
*
|
|
419
|
+
* ```ts
|
|
420
|
+
* // Select cars made by Ford or GM.
|
|
421
|
+
* db.select().from(cars)
|
|
422
|
+
* .where(inArray(cars.make, ['Ford', 'GM']))
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @see notInArray for the inverse of this test
|
|
426
|
+
*/
|
|
427
427
|
inArray?: TValue[];
|
|
428
428
|
/**
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
429
|
+
* Test whether the first parameter, a column or expression,
|
|
430
|
+
* has a value that is not present in a list passed as the
|
|
431
|
+
* second argument.
|
|
432
|
+
*
|
|
433
|
+
* ## Throws
|
|
434
|
+
*
|
|
435
|
+
* The argument passed in the second array can't be empty:
|
|
436
|
+
* if an empty is provided, this method will throw.
|
|
437
|
+
*
|
|
438
|
+
* ## Examples
|
|
439
|
+
*
|
|
440
|
+
* ```ts
|
|
441
|
+
* // Select cars made by any company except Ford or GM.
|
|
442
|
+
* db.select().from(cars)
|
|
443
|
+
* .where(notInArray(cars.make, ['Ford', 'GM']))
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @see inArray for the inverse of this test
|
|
447
|
+
*/
|
|
448
448
|
notInArray?: TValue[];
|
|
449
449
|
/**
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
450
|
+
* Test whether an expression is not NULL. By the SQL standard,
|
|
451
|
+
* NULL is neither equal nor not equal to itself, so
|
|
452
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
453
|
+
* comparisons to NULL.
|
|
454
|
+
*
|
|
455
|
+
* ## Examples
|
|
456
|
+
*
|
|
457
|
+
* ```ts
|
|
458
|
+
* // Select cars that have been discontinued.
|
|
459
|
+
* db.select().from(cars)
|
|
460
|
+
* .where(isNotNull(cars.discontinuedAt))
|
|
461
|
+
* ```
|
|
462
|
+
*
|
|
463
|
+
* @see isNull for the inverse of this test
|
|
464
|
+
*/
|
|
465
465
|
isNotNull?: true;
|
|
466
466
|
/**
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
467
|
+
* Test whether an expression is NULL. By the SQL standard,
|
|
468
|
+
* NULL is neither equal nor not equal to itself, so
|
|
469
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
470
|
+
* comparisons to NULL.
|
|
471
|
+
*
|
|
472
|
+
* ## Examples
|
|
473
|
+
*
|
|
474
|
+
* ```ts
|
|
475
|
+
* // Select cars that have no discontinuedAt date.
|
|
476
|
+
* db.select().from(cars)
|
|
477
|
+
* .where(isNull(cars.discontinuedAt))
|
|
478
|
+
* ```
|
|
479
|
+
*
|
|
480
|
+
* @see isNotNull for the inverse of this test
|
|
481
|
+
*/
|
|
482
482
|
isNull?: true;
|
|
483
483
|
/**
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
484
|
+
* Test whether an expression is between two values. This
|
|
485
|
+
* is an easier way to express range tests, which would be
|
|
486
|
+
* expressed mathematically as `x <= a <= y` but in SQL
|
|
487
|
+
* would have to be like `a >= x AND a <= y`.
|
|
488
|
+
*
|
|
489
|
+
* Between is inclusive of the endpoints: if `column`
|
|
490
|
+
* is equal to `min` or `max`, it will be TRUE.
|
|
491
|
+
*
|
|
492
|
+
* ## Examples
|
|
493
|
+
*
|
|
494
|
+
* ```ts
|
|
495
|
+
* // Select cars made between 1990 and 2000
|
|
496
|
+
* db.select().from(cars)
|
|
497
|
+
* .where(between(cars.year, 1990, 2000))
|
|
498
|
+
* ```
|
|
499
|
+
*
|
|
500
|
+
* @see notBetween for the inverse of this test
|
|
501
|
+
*/
|
|
502
502
|
between?: [number, number];
|
|
503
503
|
/**
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
504
|
+
* Test whether an expression is not between two values.
|
|
505
|
+
*
|
|
506
|
+
* This, like `between`, includes its endpoints, so if
|
|
507
|
+
* the `column` is equal to `min` or `max`, in this case
|
|
508
|
+
* it will evaluate to FALSE.
|
|
509
|
+
*
|
|
510
|
+
* ## Examples
|
|
511
|
+
*
|
|
512
|
+
* ```ts
|
|
513
|
+
* // Exclude cars made in the 1970s
|
|
514
|
+
* db.select().from(cars)
|
|
515
|
+
* .where(notBetween(cars.year, 1970, 1979))
|
|
516
|
+
* ```
|
|
517
|
+
*
|
|
518
|
+
* @see between for the inverse of this test
|
|
519
|
+
*/
|
|
520
520
|
notBetween?: [number, number];
|
|
521
521
|
/**
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
522
|
+
* Compare a column to a pattern, which can include `%` and `_`
|
|
523
|
+
* characters to match multiple variations. Including `%`
|
|
524
|
+
* in the pattern matches zero or more characters, and including
|
|
525
|
+
* `_` will match a single character.
|
|
526
|
+
*
|
|
527
|
+
* ## Examples
|
|
528
|
+
*
|
|
529
|
+
* ```ts
|
|
530
|
+
* // Select all cars with 'Turbo' in their names.
|
|
531
|
+
* db.select().from(cars)
|
|
532
|
+
* .where(like(cars.name, '%Turbo%'))
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @see ilike for a case-insensitive version of this condition
|
|
536
|
+
*/
|
|
537
537
|
like?: string;
|
|
538
538
|
/**
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
539
|
+
* The inverse of like - this tests that a given column
|
|
540
|
+
* does not match a pattern, which can include `%` and `_`
|
|
541
|
+
* characters to match multiple variations. Including `%`
|
|
542
|
+
* in the pattern matches zero or more characters, and including
|
|
543
|
+
* `_` will match a single character.
|
|
544
|
+
*
|
|
545
|
+
* ## Examples
|
|
546
|
+
*
|
|
547
|
+
* ```ts
|
|
548
|
+
* // Select all cars that don't have "ROver" in their name.
|
|
549
|
+
* db.select().from(cars)
|
|
550
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
551
|
+
* ```
|
|
552
|
+
*
|
|
553
|
+
* @see like for the inverse condition
|
|
554
|
+
* @see notIlike for a case-insensitive version of this condition
|
|
555
|
+
*/
|
|
556
556
|
notLike?: string;
|
|
557
557
|
/**
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
558
|
+
* Case-insensitively compare a column to a pattern,
|
|
559
|
+
* which can include `%` and `_`
|
|
560
|
+
* characters to match multiple variations. Including `%`
|
|
561
|
+
* in the pattern matches zero or more characters, and including
|
|
562
|
+
* `_` will match a single character.
|
|
563
|
+
*
|
|
564
|
+
* Unlike like, this performs a case-insensitive comparison.
|
|
565
|
+
*
|
|
566
|
+
* ## Examples
|
|
567
|
+
*
|
|
568
|
+
* ```ts
|
|
569
|
+
* // Select all cars with 'Turbo' in their names.
|
|
570
|
+
* db.select().from(cars)
|
|
571
|
+
* .where(ilike(cars.name, '%Turbo%'))
|
|
572
|
+
* ```
|
|
573
|
+
*
|
|
574
|
+
* @see like for a case-sensitive version of this condition
|
|
575
|
+
*/
|
|
576
576
|
ilike?: string;
|
|
577
577
|
/**
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
578
|
+
* The inverse of ilike - this case-insensitively tests that a given column
|
|
579
|
+
* does not match a pattern, which can include `%` and `_`
|
|
580
|
+
* characters to match multiple variations. Including `%`
|
|
581
|
+
* in the pattern matches zero or more characters, and including
|
|
582
|
+
* `_` will match a single character.
|
|
583
|
+
*
|
|
584
|
+
* ## Examples
|
|
585
|
+
*
|
|
586
|
+
* ```ts
|
|
587
|
+
* // Select all cars that don't have "Rover" in their name.
|
|
588
|
+
* db.select().from(cars)
|
|
589
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
590
|
+
* ```
|
|
591
|
+
*
|
|
592
|
+
* @see ilike for the inverse condition
|
|
593
|
+
* @see notLike for a case-sensitive version of this condition
|
|
594
|
+
*/
|
|
595
595
|
notIlike?: string;
|
|
596
596
|
/**
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
597
|
+
* Syntactic sugar for case-insensitive substring matching.
|
|
598
|
+
* Automatically wraps the value with `%` wildcards on both sides.
|
|
599
|
+
*
|
|
600
|
+
* Equivalent to: `ilike: '%value%'`
|
|
601
|
+
*
|
|
602
|
+
* ## Examples
|
|
603
|
+
*
|
|
604
|
+
* ```ts
|
|
605
|
+
* // Select all cars with "Turbo" anywhere in their name.
|
|
606
|
+
* db.select().from(cars)
|
|
607
|
+
* .where({ name: { contains: 'Turbo' } })
|
|
608
|
+
* // Same as: .where(ilike(cars.name, '%Turbo%'))
|
|
609
|
+
* ```
|
|
610
|
+
*
|
|
611
|
+
* @see ilike for manual pattern matching
|
|
612
|
+
* @see startsWith for prefix matching
|
|
613
|
+
* @see endsWith for suffix matching
|
|
614
|
+
*/
|
|
615
615
|
contains?: string;
|
|
616
616
|
/**
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
617
|
+
* Syntactic sugar for case-insensitive prefix matching.
|
|
618
|
+
* Automatically appends a `%` wildcard to the end of the value.
|
|
619
|
+
*
|
|
620
|
+
* Equivalent to: `ilike: 'value%'`
|
|
621
|
+
*
|
|
622
|
+
* ## Examples
|
|
623
|
+
*
|
|
624
|
+
* ```ts
|
|
625
|
+
* // Select all cars whose names start with "Ford".
|
|
626
|
+
* db.select().from(cars)
|
|
627
|
+
* .where({ name: { startsWith: 'Ford' } })
|
|
628
|
+
* // Same as: .where(ilike(cars.name, 'Ford%'))
|
|
629
|
+
* ```
|
|
630
|
+
*
|
|
631
|
+
* @see ilike for manual pattern matching
|
|
632
|
+
* @see contains for substring matching
|
|
633
|
+
* @see endsWith for suffix matching
|
|
634
|
+
*/
|
|
635
635
|
startsWith?: string;
|
|
636
636
|
/**
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
637
|
+
* Syntactic sugar for case-insensitive suffix matching.
|
|
638
|
+
* Automatically prepends a `%` wildcard to the beginning of the value.
|
|
639
|
+
*
|
|
640
|
+
* Equivalent to: `ilike: '%value'`
|
|
641
|
+
*
|
|
642
|
+
* ## Examples
|
|
643
|
+
*
|
|
644
|
+
* ```ts
|
|
645
|
+
* // Select all cars whose names end with "Turbo".
|
|
646
|
+
* db.select().from(cars)
|
|
647
|
+
* .where({ name: { endsWith: 'Turbo' } })
|
|
648
|
+
* // Same as: .where(ilike(cars.name, '%Turbo'))
|
|
649
|
+
* ```
|
|
650
|
+
*
|
|
651
|
+
* @see ilike for manual pattern matching
|
|
652
|
+
* @see contains for substring matching
|
|
653
|
+
* @see startsWith for prefix matching
|
|
654
|
+
*/
|
|
655
655
|
endsWith?: string;
|
|
656
656
|
/**
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
657
|
+
* Test that a column or expression contains all elements of
|
|
658
|
+
* the list passed as the second argument.
|
|
659
|
+
*
|
|
660
|
+
* ## Throws
|
|
661
|
+
*
|
|
662
|
+
* The argument passed in the second array can't be empty:
|
|
663
|
+
* if an empty is provided, this method will throw.
|
|
664
|
+
*
|
|
665
|
+
* ## Examples
|
|
666
|
+
*
|
|
667
|
+
* ```ts
|
|
668
|
+
* // Select posts where its tags contain "Typescript" and "ORM".
|
|
669
|
+
* db.select().from(posts)
|
|
670
|
+
* .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
|
|
671
|
+
* ```
|
|
672
|
+
*
|
|
673
|
+
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
674
|
+
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
675
|
+
*/
|
|
676
676
|
arrayContains?: TValue;
|
|
677
677
|
/**
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
678
|
+
* Test that the list passed as the second argument contains
|
|
679
|
+
* all elements of a column or expression.
|
|
680
|
+
*
|
|
681
|
+
* ## Throws
|
|
682
|
+
*
|
|
683
|
+
* The argument passed in the second array can't be empty:
|
|
684
|
+
* if an empty is provided, this method will throw.
|
|
685
|
+
*
|
|
686
|
+
* ## Examples
|
|
687
|
+
*
|
|
688
|
+
* ```ts
|
|
689
|
+
* // Select posts where its tags contain "Typescript", "ORM" or both,
|
|
690
|
+
* // but filtering posts that have additional tags.
|
|
691
|
+
* db.select().from(posts)
|
|
692
|
+
* .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
|
|
693
|
+
* ```
|
|
694
|
+
*
|
|
695
|
+
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
696
|
+
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
697
|
+
*/
|
|
698
698
|
arrayContained?: TValue;
|
|
699
699
|
/**
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
700
|
+
* Test that a column or expression contains any elements of
|
|
701
|
+
* the list passed as the second argument.
|
|
702
|
+
*
|
|
703
|
+
* ## Throws
|
|
704
|
+
*
|
|
705
|
+
* The argument passed in the second array can't be empty:
|
|
706
|
+
* if an empty is provided, this method will throw.
|
|
707
|
+
*
|
|
708
|
+
* ## Examples
|
|
709
|
+
*
|
|
710
|
+
* ```ts
|
|
711
|
+
* // Select posts where its tags contain "Typescript", "ORM" or both.
|
|
712
|
+
* db.select().from(posts)
|
|
713
|
+
* .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
|
|
714
|
+
* ```
|
|
715
|
+
*
|
|
716
|
+
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
717
|
+
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
718
|
+
*/
|
|
719
719
|
arrayOverlaps?: TValue;
|
|
720
720
|
}
|
|
721
721
|
//#endregion
|
|
@@ -774,71 +774,71 @@ type PgQueryWhereOrSQL<T extends TObject, Relations extends PgRelationMap<TObjec
|
|
|
774
774
|
type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key] };
|
|
775
775
|
type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = {
|
|
776
776
|
/**
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
777
|
+
* Combine a list of conditions with the `and` operator. Conditions
|
|
778
|
+
* that are equal `undefined` are automatically ignored.
|
|
779
|
+
*
|
|
780
|
+
* ## Examples
|
|
781
|
+
*
|
|
782
|
+
* ```ts
|
|
783
|
+
* db.select().from(cars)
|
|
784
|
+
* .where(
|
|
785
|
+
* and(
|
|
786
|
+
* eq(cars.make, 'Volvo'),
|
|
787
|
+
* eq(cars.year, 1950),
|
|
788
|
+
* )
|
|
789
|
+
* )
|
|
790
|
+
* ```
|
|
791
|
+
*/
|
|
792
792
|
and?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
793
793
|
/**
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
794
|
+
* Combine a list of conditions with the `or` operator. Conditions
|
|
795
|
+
* that are equal `undefined` are automatically ignored.
|
|
796
|
+
*
|
|
797
|
+
* ## Examples
|
|
798
|
+
*
|
|
799
|
+
* ```ts
|
|
800
|
+
* db.select().from(cars)
|
|
801
|
+
* .where(
|
|
802
|
+
* or(
|
|
803
|
+
* eq(cars.make, 'GM'),
|
|
804
|
+
* eq(cars.make, 'Ford'),
|
|
805
|
+
* )
|
|
806
|
+
* )
|
|
807
|
+
* ```
|
|
808
|
+
*/
|
|
809
809
|
or?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
810
810
|
/**
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
811
|
+
* Negate the meaning of an expression using the `not` keyword.
|
|
812
|
+
*
|
|
813
|
+
* ## Examples
|
|
814
|
+
*
|
|
815
|
+
* ```ts
|
|
816
|
+
* // Select cars _not_ made by GM or Ford.
|
|
817
|
+
* db.select().from(cars)
|
|
818
|
+
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
821
|
not?: PgQueryWhereOrSQL<T, Relations>;
|
|
822
822
|
/**
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
823
|
+
* Test whether a subquery evaluates to have any rows.
|
|
824
|
+
*
|
|
825
|
+
* ## Examples
|
|
826
|
+
*
|
|
827
|
+
* ```ts
|
|
828
|
+
* // Users whose `homeCity` column has a match in a cities
|
|
829
|
+
* // table.
|
|
830
|
+
* db
|
|
831
|
+
* .select()
|
|
832
|
+
* .from(users)
|
|
833
|
+
* .where(
|
|
834
|
+
* exists(db.select()
|
|
835
|
+
* .from(cities)
|
|
836
|
+
* .where(eq(users.homeCity, cities.id))),
|
|
837
|
+
* );
|
|
838
|
+
* ```
|
|
839
|
+
*
|
|
840
|
+
* @see notExists for the inverse of this test
|
|
841
|
+
*/
|
|
842
842
|
exists?: SQLWrapper;
|
|
843
843
|
};
|
|
844
844
|
type PgQueryWhereRelations<Relations extends PgRelationMap<TObject> | undefined = undefined> = Relations extends PgRelationMap<TObject> ? { [K in keyof Relations]?: PgQueryWhere<Relations[K]["join"]["schema"], Relations[K]["with"]> } : {};
|
|
@@ -947,81 +947,81 @@ interface PgAttrField {
|
|
|
947
947
|
declare class DatabaseTypeProvider {
|
|
948
948
|
readonly attr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
|
|
949
949
|
/**
|
|
950
|
-
|
|
951
|
-
|
|
950
|
+
* Creates a primary key with an identity column.
|
|
951
|
+
*/
|
|
952
952
|
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
953
953
|
/**
|
|
954
|
-
|
|
955
|
-
|
|
954
|
+
* Creates a primary key with a big identity column. (default)
|
|
955
|
+
*/
|
|
956
956
|
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
957
957
|
/**
|
|
958
|
-
|
|
959
|
-
|
|
958
|
+
* Creates a primary key with a UUID column.
|
|
959
|
+
*/
|
|
960
960
|
readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
961
961
|
/**
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
962
|
+
* Creates a primary key for a given type. Supports:
|
|
963
|
+
* - `t.integer()` -> PG INT (default)
|
|
964
|
+
* - `t.bigint()` -> PG BIGINT
|
|
965
|
+
* - `t.uuid()` -> PG UUID
|
|
966
|
+
*/
|
|
967
967
|
primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
968
968
|
primaryKey(type: TString, options?: TStringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
|
|
969
969
|
primaryKey(type: TInteger, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
970
970
|
primaryKey(type: TNumber, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
|
|
971
971
|
primaryKey(type: TBigInt, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TBigInt, PgPrimaryKey>, PgDefault>;
|
|
972
972
|
/**
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
973
|
+
* Wrap a schema with "default" attribute.
|
|
974
|
+
* This is used to set a default value for a column in the database.
|
|
975
|
+
*/
|
|
976
976
|
readonly default: <T extends TSchema>(type: T, value?: Static<T>) => PgAttr<T, PgDefault>;
|
|
977
977
|
/**
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
978
|
+
* Creates a column 'version'.
|
|
979
|
+
*
|
|
980
|
+
* This is used to track the version of a row in the database.
|
|
981
|
+
*
|
|
982
|
+
* You can use it for optimistic concurrency control (OCC) with {@link RepositoryPrimitive#save}.
|
|
983
|
+
*
|
|
984
|
+
* @see {@link RepositoryPrimitive#save}
|
|
985
|
+
* @see {@link PgVersionMismatchError}
|
|
986
|
+
*/
|
|
987
987
|
readonly version: (options?: TNumberOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
988
988
|
/**
|
|
989
|
-
|
|
990
|
-
|
|
989
|
+
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
990
|
+
*/
|
|
991
991
|
readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
992
992
|
/**
|
|
993
|
-
|
|
994
|
-
|
|
993
|
+
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
994
|
+
*/
|
|
995
995
|
readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
996
996
|
/**
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
997
|
+
* Creates a column Deleted At for soft delete functionality.
|
|
998
|
+
* This is used to mark rows as deleted without actually removing them from the database.
|
|
999
|
+
* The column is nullable - NULL means not deleted, timestamp means deleted.
|
|
1000
|
+
*/
|
|
1001
1001
|
readonly deletedAt: (options?: TStringOptions) => PgAttr<alepha34.TOptional<TString>, typeof PG_DELETED_AT>;
|
|
1002
1002
|
/**
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1003
|
+
* Creates a Postgres ENUM type.
|
|
1004
|
+
*
|
|
1005
|
+
* > By default, `t.enum()` is mapped to a TEXT column in Postgres.
|
|
1006
|
+
* > Using this method, you can create a real ENUM type in the database.
|
|
1007
|
+
*
|
|
1008
|
+
* @example
|
|
1009
|
+
* ```ts
|
|
1010
|
+
* const statusEnum = pg.enum(["pending", "active", "archived"], { name: "status_enum" });
|
|
1011
|
+
* ```
|
|
1012
|
+
*/
|
|
1013
1013
|
readonly enum: <T extends string[]>(values: [...T], pgEnumOptions?: PgEnumOptions, typeOptions?: TStringOptions) => PgAttr<TUnsafe<T[number]>, typeof PG_ENUM>;
|
|
1014
1014
|
/**
|
|
1015
|
-
|
|
1016
|
-
|
|
1015
|
+
* Creates a reference to another table or schema. Basically a foreign key.
|
|
1016
|
+
*/
|
|
1017
1017
|
readonly ref: <T extends TSchema>(type: T, ref: () => any, actions?: {
|
|
1018
1018
|
onUpdate?: UpdateDeleteAction$1;
|
|
1019
1019
|
onDelete?: UpdateDeleteAction$1;
|
|
1020
1020
|
}) => PgAttr<T, PgRef>;
|
|
1021
1021
|
/**
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1022
|
+
* Creates a page schema for a given object schema.
|
|
1023
|
+
* It's used by {@link Repository#paginate} method.
|
|
1024
|
+
*/
|
|
1025
1025
|
readonly page: <T extends TObject>(resource: T, options?: TObjectOptions) => TPage<T>;
|
|
1026
1026
|
}
|
|
1027
1027
|
/**
|
|
@@ -1063,8 +1063,8 @@ declare const $sequence: {
|
|
|
1063
1063
|
};
|
|
1064
1064
|
interface SequencePrimitiveOptions extends PgSequenceOptions {
|
|
1065
1065
|
/**
|
|
1066
|
-
|
|
1067
|
-
|
|
1066
|
+
* The name of the sequence. If not provided, the property key will be used.
|
|
1067
|
+
*/
|
|
1068
1068
|
name?: string;
|
|
1069
1069
|
provider?: DatabaseProvider;
|
|
1070
1070
|
}
|
|
@@ -1104,72 +1104,72 @@ interface TableConfigBuilders<TConfig> {
|
|
|
1104
1104
|
*/
|
|
1105
1105
|
declare abstract class ModelBuilder {
|
|
1106
1106
|
/**
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
* Build a table from an entity primitive.
|
|
1108
|
+
*/
|
|
1109
1109
|
abstract buildTable(entity: EntityPrimitive, options: {
|
|
1110
1110
|
tables: Map<string, unknown>;
|
|
1111
1111
|
enums: Map<string, unknown>;
|
|
1112
1112
|
schema: string;
|
|
1113
1113
|
}): void;
|
|
1114
1114
|
/**
|
|
1115
|
-
|
|
1116
|
-
|
|
1115
|
+
* Build a sequence from a sequence primitive.
|
|
1116
|
+
*/
|
|
1117
1117
|
abstract buildSequence(sequence: SequencePrimitive, options: {
|
|
1118
1118
|
sequences: Map<string, unknown>;
|
|
1119
1119
|
schema: string;
|
|
1120
1120
|
}): void;
|
|
1121
1121
|
/**
|
|
1122
|
-
|
|
1123
|
-
|
|
1122
|
+
* Convert camelCase to snake_case for column names.
|
|
1123
|
+
*/
|
|
1124
1124
|
protected toColumnName(str: string): string;
|
|
1125
1125
|
/**
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1126
|
+
* Build the table configuration function for any database.
|
|
1127
|
+
* This includes indexes, foreign keys, constraints, and custom config.
|
|
1128
|
+
*
|
|
1129
|
+
* @param entity - The entity primitive
|
|
1130
|
+
* @param builders - Database-specific builder functions
|
|
1131
|
+
* @param tableResolver - Function to resolve entity references to table columns
|
|
1132
|
+
* @param customConfigHandler - Optional handler for custom config
|
|
1133
|
+
*/
|
|
1134
1134
|
protected buildTableConfig<TConfig, TSelf>(entity: EntityPrimitive, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
|
|
1135
1135
|
}
|
|
1136
1136
|
//#endregion
|
|
1137
1137
|
//#region ../../src/orm/providers/DrizzleKitProvider.d.ts
|
|
1138
1138
|
declare class DrizzleKitProvider {
|
|
1139
|
-
protected readonly log:
|
|
1139
|
+
protected readonly log: alepha_logger4.Logger;
|
|
1140
1140
|
protected readonly alepha: Alepha;
|
|
1141
1141
|
/**
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1142
|
+
* Synchronize database with current schema definitions.
|
|
1143
|
+
*
|
|
1144
|
+
* In development mode, it will generate and execute migrations based on the current state.
|
|
1145
|
+
* In testing mode, it will generate migrations from scratch without applying them.
|
|
1146
|
+
*
|
|
1147
|
+
* Does nothing in production mode, you must handle migrations manually.
|
|
1148
|
+
*/
|
|
1149
1149
|
synchronize(provider: DatabaseProvider): Promise<void>;
|
|
1150
1150
|
/**
|
|
1151
|
-
|
|
1152
|
-
|
|
1151
|
+
* Mostly used for testing purposes. You can generate SQL migration statements without executing them.
|
|
1152
|
+
*/
|
|
1153
1153
|
generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
|
|
1154
1154
|
statements: string[];
|
|
1155
1155
|
models: Record<string, unknown>;
|
|
1156
1156
|
snapshot?: any;
|
|
1157
1157
|
}>;
|
|
1158
1158
|
/**
|
|
1159
|
-
|
|
1160
|
-
|
|
1159
|
+
* Load all tables, enums, sequences, etc. from the provider's repositories.
|
|
1160
|
+
*/
|
|
1161
1161
|
getModels(provider: DatabaseProvider): Record<string, unknown>;
|
|
1162
1162
|
/**
|
|
1163
|
-
|
|
1164
|
-
|
|
1163
|
+
* Load the migration snapshot from the database.
|
|
1164
|
+
*/
|
|
1165
1165
|
protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
|
|
1166
1166
|
protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
|
|
1167
1167
|
protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
|
|
1168
1168
|
protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
|
|
1169
1169
|
/**
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1170
|
+
* Try to load the official Drizzle Kit API.
|
|
1171
|
+
* If not available, fallback to the local kit import.
|
|
1172
|
+
*/
|
|
1173
1173
|
importDrizzleKit(): typeof DrizzleKit;
|
|
1174
1174
|
}
|
|
1175
1175
|
declare const devMigrationsSchema: alepha34.TObject<{
|
|
@@ -1184,7 +1184,7 @@ type DevMigrations = Static<typeof devMigrationsSchema>;
|
|
|
1184
1184
|
type SQLLike = SQLWrapper | string;
|
|
1185
1185
|
declare abstract class DatabaseProvider {
|
|
1186
1186
|
protected readonly alepha: Alepha;
|
|
1187
|
-
protected readonly log:
|
|
1187
|
+
protected readonly log: alepha_logger4.Logger;
|
|
1188
1188
|
protected abstract readonly builder: ModelBuilder;
|
|
1189
1189
|
protected abstract readonly kit: DrizzleKitProvider;
|
|
1190
1190
|
abstract readonly db: PgDatabase<any>;
|
|
@@ -1202,39 +1202,39 @@ declare abstract class DatabaseProvider {
|
|
|
1202
1202
|
abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
|
|
1203
1203
|
run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
|
|
1204
1204
|
/**
|
|
1205
|
-
|
|
1206
|
-
|
|
1205
|
+
* Get migrations folder path - can be overridden
|
|
1206
|
+
*/
|
|
1207
1207
|
protected getMigrationsFolder(): string;
|
|
1208
1208
|
/**
|
|
1209
|
-
|
|
1210
|
-
|
|
1209
|
+
* Base migration orchestration - handles environment logic
|
|
1210
|
+
*/
|
|
1211
1211
|
migrate(): Promise<void>;
|
|
1212
1212
|
/**
|
|
1213
|
-
|
|
1214
|
-
|
|
1213
|
+
* Production: run migrations from folder
|
|
1214
|
+
*/
|
|
1215
1215
|
protected runProductionMigration(migrationsFolder: string): Promise<void>;
|
|
1216
1216
|
/**
|
|
1217
|
-
|
|
1218
|
-
|
|
1217
|
+
* Test: always synchronize
|
|
1218
|
+
*/
|
|
1219
1219
|
protected runTestMigration(): Promise<void>;
|
|
1220
1220
|
/**
|
|
1221
|
-
|
|
1222
|
-
|
|
1221
|
+
* Development: default to synchronize (can be overridden)
|
|
1222
|
+
*/
|
|
1223
1223
|
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
1224
1224
|
/**
|
|
1225
|
-
|
|
1226
|
-
|
|
1225
|
+
* Common synchronization with error handling
|
|
1226
|
+
*/
|
|
1227
1227
|
protected synchronizeSchema(): Promise<void>;
|
|
1228
1228
|
/**
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1229
|
+
* Provider-specific migration execution
|
|
1230
|
+
* MUST be implemented by each provider
|
|
1231
|
+
*/
|
|
1232
1232
|
protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1233
1233
|
/**
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1234
|
+
* For testing purposes, generate a unique schema name.
|
|
1235
|
+
* The schema name will be generated based on the current date and time.
|
|
1236
|
+
* It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
|
|
1237
|
+
*/
|
|
1238
1238
|
protected generateTestSchemaName(): string;
|
|
1239
1239
|
}
|
|
1240
1240
|
//#endregion
|
|
@@ -1242,8 +1242,8 @@ declare abstract class DatabaseProvider {
|
|
|
1242
1242
|
declare class QueryManager {
|
|
1243
1243
|
protected readonly alepha: Alepha;
|
|
1244
1244
|
/**
|
|
1245
|
-
|
|
1246
|
-
|
|
1245
|
+
* Convert a query object to a SQL query.
|
|
1246
|
+
*/
|
|
1247
1247
|
toSQL(query: PgQueryWhereOrSQL<TObject>, options: {
|
|
1248
1248
|
schema: TObject;
|
|
1249
1249
|
col: (key: string) => PgColumn;
|
|
@@ -1251,22 +1251,22 @@ declare class QueryManager {
|
|
|
1251
1251
|
dialect: "postgresql" | "sqlite";
|
|
1252
1252
|
}): SQL | undefined;
|
|
1253
1253
|
/**
|
|
1254
|
-
|
|
1255
|
-
|
|
1254
|
+
* Check if an object has any filter operator properties.
|
|
1255
|
+
*/
|
|
1256
1256
|
protected hasFilterOperatorProperties(obj: any): boolean;
|
|
1257
1257
|
/**
|
|
1258
|
-
|
|
1259
|
-
|
|
1258
|
+
* Map a filter operator to a SQL query.
|
|
1259
|
+
*/
|
|
1260
1260
|
mapOperatorToSql(operator: FilterOperators<any> | any, column: PgColumn, columnSchema?: TObject, columnName?: string, dialect?: "postgresql" | "sqlite"): SQL | undefined;
|
|
1261
1261
|
/**
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1262
|
+
* Parse pagination sort string to orderBy format.
|
|
1263
|
+
* Format: "firstName,-lastName" -> [{ column: "firstName", direction: "asc" }, { column: "lastName", direction: "desc" }]
|
|
1264
|
+
* - Columns separated by comma
|
|
1265
|
+
* - Prefix with '-' for DESC direction
|
|
1266
|
+
*
|
|
1267
|
+
* @param sort Pagination sort string
|
|
1268
|
+
* @returns OrderBy array or single object
|
|
1269
|
+
*/
|
|
1270
1270
|
parsePaginationSort(sort: string): Array<{
|
|
1271
1271
|
column: string;
|
|
1272
1272
|
direction: "asc" | "desc";
|
|
@@ -1275,30 +1275,30 @@ declare class QueryManager {
|
|
|
1275
1275
|
direction: "asc" | "desc";
|
|
1276
1276
|
};
|
|
1277
1277
|
/**
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1278
|
+
* Normalize orderBy parameter to array format.
|
|
1279
|
+
* Supports 3 modes:
|
|
1280
|
+
* 1. String: "name" -> [{ column: "name", direction: "asc" }]
|
|
1281
|
+
* 2. Object: { column: "name", direction: "desc" } -> [{ column: "name", direction: "desc" }]
|
|
1282
|
+
* 3. Array: [{ column: "name" }, { column: "age", direction: "desc" }] -> normalized array
|
|
1283
|
+
*
|
|
1284
|
+
* @param orderBy The orderBy parameter
|
|
1285
|
+
* @returns Normalized array of order by clauses
|
|
1286
|
+
*/
|
|
1287
1287
|
normalizeOrderBy(orderBy: any): Array<{
|
|
1288
1288
|
column: string;
|
|
1289
1289
|
direction: "asc" | "desc";
|
|
1290
1290
|
}>;
|
|
1291
1291
|
/**
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1292
|
+
* Create a pagination object.
|
|
1293
|
+
*
|
|
1294
|
+
* @deprecated Use `createPagination` from alepha instead.
|
|
1295
|
+
* This method now delegates to the framework-level helper.
|
|
1296
|
+
*
|
|
1297
|
+
* @param entities The entities to paginate.
|
|
1298
|
+
* @param limit The limit of the pagination.
|
|
1299
|
+
* @param offset The offset of the pagination.
|
|
1300
|
+
* @param sort Optional sort metadata to include in response.
|
|
1301
|
+
*/
|
|
1302
1302
|
createPagination<T>(entities: T[], limit?: number, offset?: number, sort?: Array<{
|
|
1303
1303
|
column: string;
|
|
1304
1304
|
direction: "asc" | "desc";
|
|
@@ -1315,20 +1315,20 @@ interface PgJoin {
|
|
|
1315
1315
|
//#region ../../src/orm/services/PgRelationManager.d.ts
|
|
1316
1316
|
declare class PgRelationManager {
|
|
1317
1317
|
/**
|
|
1318
|
-
|
|
1319
|
-
|
|
1318
|
+
* Recursively build joins for the query builder based on the relations map
|
|
1319
|
+
*/
|
|
1320
1320
|
buildJoins(provider: DatabaseProvider, builder: PgSelectBase<any, any, any>, joins: Array<PgJoin>, withRelations: PgRelationMap<TObject>, table: PgTableWithColumns<any>, parentKey?: string): void;
|
|
1321
1321
|
/**
|
|
1322
|
-
|
|
1323
|
-
|
|
1322
|
+
* Map a row with its joined relations based on the joins definition
|
|
1323
|
+
*/
|
|
1324
1324
|
mapRowWithJoins(record: Record<string, unknown>, row: Record<string, unknown>, schema: TObject, joins: PgJoin[], parentKey?: string): Record<string, unknown>;
|
|
1325
1325
|
/**
|
|
1326
|
-
|
|
1327
|
-
|
|
1326
|
+
* Check if all values in an object are null (indicates a left join with no match)
|
|
1327
|
+
*/
|
|
1328
1328
|
private isAllNull;
|
|
1329
1329
|
/**
|
|
1330
|
-
|
|
1331
|
-
|
|
1330
|
+
* Build a schema that includes all join properties recursively
|
|
1331
|
+
*/
|
|
1332
1332
|
buildSchemaWithJoins(baseSchema: TObject, joins: PgJoin[], parentPath?: string): TObject;
|
|
1333
1333
|
}
|
|
1334
1334
|
//#endregion
|
|
@@ -1336,217 +1336,218 @@ declare class PgRelationManager {
|
|
|
1336
1336
|
declare abstract class Repository<T extends TObject> {
|
|
1337
1337
|
readonly entity: EntityPrimitive<T>;
|
|
1338
1338
|
readonly provider: DatabaseProvider;
|
|
1339
|
-
protected readonly log:
|
|
1339
|
+
protected readonly log: alepha_logger4.Logger;
|
|
1340
1340
|
protected readonly relationManager: PgRelationManager;
|
|
1341
1341
|
protected readonly queryManager: QueryManager;
|
|
1342
1342
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
1343
1343
|
protected readonly alepha: Alepha;
|
|
1344
|
+
static of<T extends TObject>(entity: EntityPrimitive<T>, provider?: typeof DatabaseProvider): new () => Repository<T>;
|
|
1344
1345
|
constructor(entity: EntityPrimitive<T>, provider?: typeof DatabaseProvider);
|
|
1345
1346
|
/**
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1347
|
+
* Represents the primary key of the table.
|
|
1348
|
+
* - Key is the name of the primary key column.
|
|
1349
|
+
* - Type is the type (TypeBox) of the primary key column.
|
|
1350
|
+
*
|
|
1351
|
+
* ID is mandatory. If the table does not have a primary key, it will throw an error.
|
|
1352
|
+
*/
|
|
1352
1353
|
get id(): {
|
|
1353
1354
|
type: TSchema;
|
|
1354
1355
|
key: keyof T["properties"];
|
|
1355
1356
|
col: PgColumn;
|
|
1356
1357
|
};
|
|
1357
1358
|
/**
|
|
1358
|
-
|
|
1359
|
-
|
|
1359
|
+
* Get Drizzle table object.
|
|
1360
|
+
*/
|
|
1360
1361
|
get table(): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
1361
1362
|
/**
|
|
1362
|
-
|
|
1363
|
-
|
|
1363
|
+
* Get SQL table name. (from Drizzle table object)
|
|
1364
|
+
*/
|
|
1364
1365
|
get tableName(): string;
|
|
1365
1366
|
/**
|
|
1366
|
-
|
|
1367
|
-
|
|
1367
|
+
* Getter for the database connection from the database provider.
|
|
1368
|
+
*/
|
|
1368
1369
|
protected get db(): PgDatabase<any>;
|
|
1369
1370
|
/**
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1371
|
+
* Execute a SQL query.
|
|
1372
|
+
*
|
|
1373
|
+
* This method allows executing raw SQL queries against the database.
|
|
1374
|
+
* This is by far the easiest way to run custom queries that are not covered by the repository's built-in methods!
|
|
1375
|
+
*
|
|
1376
|
+
* You must use the `sql` tagged template function from Drizzle ORM to create the query. https://orm.drizzle.team/docs/sql
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```ts
|
|
1380
|
+
* class App {
|
|
1381
|
+
* repository = $repository({ ... });
|
|
1382
|
+
* async getAdults() {
|
|
1383
|
+
* const users = repository.table; // Drizzle table object
|
|
1384
|
+
* await repository.query(sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
1385
|
+
* // or better
|
|
1386
|
+
* await repository.query((users) => sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
1387
|
+
* }
|
|
1388
|
+
* }
|
|
1389
|
+
* ```
|
|
1390
|
+
*/
|
|
1390
1391
|
query<R extends TObject = T>(query: SQLLike | ((table: PgTableWithColumns<SchemaToTableConfig<T>>, db: PgDatabase<any>) => SQLLike), schema?: R): Promise<Static<R>[]>;
|
|
1391
1392
|
/**
|
|
1392
|
-
|
|
1393
|
-
|
|
1393
|
+
* Map raw database fields to entity fields. (handles column name differences)
|
|
1394
|
+
*/
|
|
1394
1395
|
protected mapRawFieldsToEntity(row: Record<string, unknown>): any;
|
|
1395
1396
|
/**
|
|
1396
|
-
|
|
1397
|
-
|
|
1397
|
+
* Get a Drizzle column from the table by his name.
|
|
1398
|
+
*/
|
|
1398
1399
|
protected col(name: keyof StaticEncode<T>): PgColumn;
|
|
1399
1400
|
/**
|
|
1400
|
-
|
|
1401
|
-
|
|
1401
|
+
* Run a transaction.
|
|
1402
|
+
*/
|
|
1402
1403
|
transaction<T>(transaction: (tx: PgTransaction<any, Record<string, any>, any>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
|
|
1403
1404
|
/**
|
|
1404
|
-
|
|
1405
|
-
|
|
1405
|
+
* Start a SELECT query on the table.
|
|
1406
|
+
*/
|
|
1406
1407
|
protected rawSelect(opts?: StatementOptions): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
|
|
1407
1408
|
[x: string]: unknown;
|
|
1408
1409
|
}[], {
|
|
1409
1410
|
[x: string]: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
1410
1411
|
}>;
|
|
1411
1412
|
/**
|
|
1412
|
-
|
|
1413
|
-
|
|
1413
|
+
* Start a SELECT DISTINCT query on the table.
|
|
1414
|
+
*/
|
|
1414
1415
|
protected rawSelectDistinct(opts?: StatementOptions, columns?: (keyof Static<T>)[]): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, any>, "partial", Record<string, "not-null">, false, never, {
|
|
1415
1416
|
[x: string]: any;
|
|
1416
1417
|
}[], {
|
|
1417
1418
|
[x: string]: any;
|
|
1418
1419
|
}>;
|
|
1419
1420
|
/**
|
|
1420
|
-
|
|
1421
|
-
|
|
1421
|
+
* Start an INSERT query on the table.
|
|
1422
|
+
*/
|
|
1422
1423
|
protected rawInsert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any, false>;
|
|
1423
1424
|
/**
|
|
1424
|
-
|
|
1425
|
-
|
|
1425
|
+
* Start an UPDATE query on the table.
|
|
1426
|
+
*/
|
|
1426
1427
|
protected rawUpdate(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any>;
|
|
1427
1428
|
/**
|
|
1428
|
-
|
|
1429
|
-
|
|
1429
|
+
* Start a DELETE query on the table.
|
|
1430
|
+
*/
|
|
1430
1431
|
protected rawDelete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<SchemaToTableConfig<T>>, any, undefined, undefined, false, never>;
|
|
1431
1432
|
/**
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1433
|
+
* Create a Drizzle `select` query based on a JSON query object.
|
|
1434
|
+
*
|
|
1435
|
+
* > This method is the base for `find`, `findOne`, `findById`, and `paginate`.
|
|
1436
|
+
*/
|
|
1436
1437
|
findMany<R extends PgRelationMap<T>>(query?: PgQueryRelations<T, R>, opts?: StatementOptions): Promise<PgStatic<T, R>[]>;
|
|
1437
1438
|
/**
|
|
1438
|
-
|
|
1439
|
-
|
|
1439
|
+
* Find a single entity.
|
|
1440
|
+
*/
|
|
1440
1441
|
findOne<R extends PgRelationMap<T>>(query: Pick<PgQueryRelations<T, R>, "with" | "where">, opts?: StatementOptions): Promise<PgStatic<T, R>>;
|
|
1441
1442
|
/**
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1443
|
+
* Find entities with pagination.
|
|
1444
|
+
*
|
|
1445
|
+
* It uses the same parameters as `find()`, but adds pagination metadata to the response.
|
|
1446
|
+
*
|
|
1447
|
+
* > Pagination CAN also do a count query to get the total number of elements.
|
|
1448
|
+
*/
|
|
1448
1449
|
paginate<R extends PgRelationMap<T>>(pagination?: PageQuery$1, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
|
|
1449
1450
|
count?: boolean;
|
|
1450
1451
|
}): Promise<Page$1<PgStatic<T, R>>>;
|
|
1451
1452
|
/**
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1453
|
+
* Find an entity by ID.
|
|
1454
|
+
*
|
|
1455
|
+
* This is a convenience method for `findOne` with a where clause on the primary key.
|
|
1456
|
+
* If you need more complex queries, use `findOne` instead.
|
|
1457
|
+
*/
|
|
1457
1458
|
findById(id: string | number, opts?: StatementOptions): Promise<Static<T>>;
|
|
1458
1459
|
/**
|
|
1459
|
-
|
|
1460
|
-
|
|
1460
|
+
* Helper to create a type-safe query object.
|
|
1461
|
+
*/
|
|
1461
1462
|
createQuery(): PgQuery<T>;
|
|
1462
1463
|
/**
|
|
1463
|
-
|
|
1464
|
-
|
|
1464
|
+
* Helper to create a type-safe where clause.
|
|
1465
|
+
*/
|
|
1465
1466
|
createQueryWhere(): PgQueryWhere<T>;
|
|
1466
1467
|
/**
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1468
|
+
* Create an entity.
|
|
1469
|
+
*
|
|
1470
|
+
* @param data The entity to create.
|
|
1471
|
+
* @param opts The options for creating the entity.
|
|
1472
|
+
* @returns The ID of the created entity.
|
|
1473
|
+
*/
|
|
1473
1474
|
create(data: Static<TObjectInsert<T>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1474
1475
|
/**
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1476
|
+
* Create many entities.
|
|
1477
|
+
*
|
|
1478
|
+
* Inserts are batched in chunks of 1000 to avoid hitting database limits.
|
|
1479
|
+
*
|
|
1480
|
+
* @param values The entities to create.
|
|
1481
|
+
* @param opts The statement options.
|
|
1482
|
+
* @returns The created entities.
|
|
1483
|
+
*/
|
|
1483
1484
|
createMany(values: Array<Static<TObjectInsert<T>>>, opts?: StatementOptions & {
|
|
1484
1485
|
batchSize?: number;
|
|
1485
1486
|
}): Promise<Static<T>[]>;
|
|
1486
1487
|
/**
|
|
1487
|
-
|
|
1488
|
-
|
|
1488
|
+
* Find an entity and update it.
|
|
1489
|
+
*/
|
|
1489
1490
|
updateOne(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1490
1491
|
/**
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1492
|
+
* Save a given entity.
|
|
1493
|
+
*
|
|
1494
|
+
* @example
|
|
1495
|
+
* ```ts
|
|
1496
|
+
* const entity = await repository.findById(1);
|
|
1497
|
+
* entity.name = "New Name"; // update a field
|
|
1498
|
+
* delete entity.description; // delete a field
|
|
1499
|
+
* await repository.save(entity);
|
|
1500
|
+
* ```
|
|
1501
|
+
*
|
|
1502
|
+
* Difference with `updateById/updateOne`:
|
|
1503
|
+
*
|
|
1504
|
+
* - requires the entity to be fetched first (whole object is expected)
|
|
1505
|
+
* - check pg.version() if present -> optimistic locking
|
|
1506
|
+
* - validate entity against schema
|
|
1507
|
+
* - undefined values will be set to null, not ignored!
|
|
1508
|
+
*
|
|
1509
|
+
* @see {@link DbVersionMismatchError}
|
|
1510
|
+
*/
|
|
1510
1511
|
save(entity: Static<T>, opts?: StatementOptions): Promise<void>;
|
|
1511
1512
|
/**
|
|
1512
|
-
|
|
1513
|
-
|
|
1513
|
+
* Find an entity by ID and update it.
|
|
1514
|
+
*/
|
|
1514
1515
|
updateById(id: string | number, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1515
1516
|
/**
|
|
1516
|
-
|
|
1517
|
-
|
|
1517
|
+
* Find many entities and update all of them.
|
|
1518
|
+
*/
|
|
1518
1519
|
updateMany(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1519
1520
|
/**
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1521
|
+
* Find many and delete all of them.
|
|
1522
|
+
* @returns Array of deleted entity IDs
|
|
1523
|
+
*/
|
|
1523
1524
|
deleteMany(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1524
1525
|
/**
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1526
|
+
* Delete all entities.
|
|
1527
|
+
* @returns Array of deleted entity IDs
|
|
1528
|
+
*/
|
|
1528
1529
|
clear(opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1529
1530
|
/**
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1531
|
+
* Delete the given entity.
|
|
1532
|
+
*
|
|
1533
|
+
* You must fetch the entity first in order to delete it.
|
|
1534
|
+
* @returns Array containing the deleted entity ID
|
|
1535
|
+
*/
|
|
1535
1536
|
destroy(entity: Static<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1536
1537
|
/**
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1538
|
+
* Find an entity and delete it.
|
|
1539
|
+
* @returns Array of deleted entity IDs (should contain at most one ID)
|
|
1540
|
+
*/
|
|
1540
1541
|
deleteOne(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1541
1542
|
/**
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1543
|
+
* Find an entity by ID and delete it.
|
|
1544
|
+
* @returns Array containing the deleted entity ID
|
|
1545
|
+
* @throws DbEntityNotFoundError if the entity is not found
|
|
1546
|
+
*/
|
|
1546
1547
|
deleteById(id: string | number, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1547
1548
|
/**
|
|
1548
|
-
|
|
1549
|
-
|
|
1549
|
+
* Count entities.
|
|
1550
|
+
*/
|
|
1550
1551
|
count(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<number>;
|
|
1551
1552
|
protected conflictMessagePattern: string;
|
|
1552
1553
|
protected handleError(error: unknown, message: string): DbError;
|
|
@@ -1555,31 +1556,31 @@ declare abstract class Repository<T extends TObject> {
|
|
|
1555
1556
|
}): PgQueryWhereOrSQL<T>;
|
|
1556
1557
|
protected deletedAt(): PgAttrField | undefined;
|
|
1557
1558
|
/**
|
|
1558
|
-
|
|
1559
|
-
|
|
1559
|
+
* Convert something to valid Pg Insert Value.
|
|
1560
|
+
*/
|
|
1560
1561
|
protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<SchemaToTableConfig<T>>>;
|
|
1561
1562
|
/**
|
|
1562
|
-
|
|
1563
|
-
|
|
1563
|
+
* Transform a row from the database into a clean entity.
|
|
1564
|
+
*/
|
|
1564
1565
|
protected clean<T extends TObject>(row: Record<string, unknown>, schema: T): Static<T>;
|
|
1565
1566
|
/**
|
|
1566
|
-
|
|
1567
|
-
|
|
1567
|
+
* Clean a row with joins recursively
|
|
1568
|
+
*/
|
|
1568
1569
|
protected cleanWithJoins<T extends TObject>(row: Record<string, unknown>, schema: T, joins: PgJoin[], parentPath?: string): Static<T>;
|
|
1569
1570
|
/**
|
|
1570
|
-
|
|
1571
|
-
|
|
1571
|
+
* Convert a where clause to SQL.
|
|
1572
|
+
*/
|
|
1572
1573
|
protected toSQL(where: PgQueryWhereOrSQL<T>, joins?: PgJoin[]): SQL | undefined;
|
|
1573
1574
|
/**
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1575
|
+
* Get the where clause for an ID.
|
|
1576
|
+
*
|
|
1577
|
+
* @param id The ID to get the where clause for.
|
|
1578
|
+
* @returns The where clause for the ID.
|
|
1579
|
+
*/
|
|
1579
1580
|
protected getWhereId(id: string | number): PgQueryWhere<T>;
|
|
1580
1581
|
/**
|
|
1581
|
-
|
|
1582
|
-
|
|
1582
|
+
* Find a primary key in the schema.
|
|
1583
|
+
*/
|
|
1583
1584
|
protected getPrimaryKey(schema: TObject): {
|
|
1584
1585
|
key: string;
|
|
1585
1586
|
col: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
@@ -1591,23 +1592,23 @@ declare abstract class Repository<T extends TObject> {
|
|
|
1591
1592
|
*/
|
|
1592
1593
|
interface StatementOptions {
|
|
1593
1594
|
/**
|
|
1594
|
-
|
|
1595
|
-
|
|
1595
|
+
* Transaction to use.
|
|
1596
|
+
*/
|
|
1596
1597
|
tx?: PgTransaction<any, Record<string, any>>;
|
|
1597
1598
|
/**
|
|
1598
|
-
|
|
1599
|
-
|
|
1599
|
+
* Lock strength.
|
|
1600
|
+
*/
|
|
1600
1601
|
for?: LockStrength | {
|
|
1601
1602
|
config: LockConfig;
|
|
1602
1603
|
strength: LockStrength;
|
|
1603
1604
|
};
|
|
1604
1605
|
/**
|
|
1605
|
-
|
|
1606
|
-
|
|
1606
|
+
* If true, ignore soft delete.
|
|
1607
|
+
*/
|
|
1607
1608
|
force?: boolean;
|
|
1608
1609
|
/**
|
|
1609
|
-
|
|
1610
|
-
|
|
1610
|
+
* Force the current time.
|
|
1611
|
+
*/
|
|
1611
1612
|
now?: DateTime | string;
|
|
1612
1613
|
}
|
|
1613
1614
|
//#endregion
|
|
@@ -1636,104 +1637,104 @@ declare const $repository: <T extends TObject>(entity: EntityPrimitive<T>) => Re
|
|
|
1636
1637
|
declare const $transaction: <T extends any[], R>(opts: TransactionPrimitiveOptions<T, R>) => alepha_retry0.RetryPrimitiveFn<(...args: T) => Promise<R>>;
|
|
1637
1638
|
interface TransactionPrimitiveOptions<T extends any[], R> {
|
|
1638
1639
|
/**
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1640
|
+
* Transaction handler function that contains all database operations to be executed atomically.
|
|
1641
|
+
*
|
|
1642
|
+
* This function:
|
|
1643
|
+
* - Receives a transaction object as the first parameter
|
|
1644
|
+
* - Should pass the transaction to all repository operations via `{ tx }` option
|
|
1645
|
+
* - All operations within are automatically rolled back if any error occurs
|
|
1646
|
+
* - Has access to the full Alepha dependency injection container
|
|
1647
|
+
* - Will be automatically retried if a `PgVersionMismatchError` occurs
|
|
1648
|
+
*
|
|
1649
|
+
* **Transaction Guidelines**:
|
|
1650
|
+
* - Keep transactions as short as possible to minimize lock contention
|
|
1651
|
+
* - Always pass the `tx` parameter to repository operations
|
|
1652
|
+
* - Handle expected business errors gracefully
|
|
1653
|
+
* - Log important operations for debugging and audit trails
|
|
1654
|
+
* - Consider the impact of long-running transactions on performance
|
|
1655
|
+
*
|
|
1656
|
+
* **Error Handling**:
|
|
1657
|
+
* - Throwing any error will automatically roll back the transaction
|
|
1658
|
+
* - `PgVersionMismatchError` triggers automatic retry logic
|
|
1659
|
+
* - Other database errors will be propagated after rollback
|
|
1660
|
+
* - Use try-catch within the handler for business-specific error handling
|
|
1661
|
+
*
|
|
1662
|
+
* @param tx - The PostgreSQL transaction object to use for all database operations
|
|
1663
|
+
* @param ...args - Additional arguments passed to the transaction function
|
|
1664
|
+
* @returns Promise resolving to the transaction result
|
|
1665
|
+
*
|
|
1666
|
+
* @example
|
|
1667
|
+
* ```ts
|
|
1668
|
+
* handler: async (tx, orderId: string, newStatus: string) => {
|
|
1669
|
+
* // Get the current order (with transaction)
|
|
1670
|
+
* const order = await this.orders.findById(orderId, { tx });
|
|
1671
|
+
*
|
|
1672
|
+
* // Validate business rules
|
|
1673
|
+
* if (!this.isValidStatusTransition(order.status, newStatus)) {
|
|
1674
|
+
* throw new Error(`Invalid status transition: ${order.status} -> ${newStatus}`);
|
|
1675
|
+
* }
|
|
1676
|
+
*
|
|
1677
|
+
* // Update order status (with transaction)
|
|
1678
|
+
* const updatedOrder = await this.orders.updateById(
|
|
1679
|
+
* orderId,
|
|
1680
|
+
* { status: newStatus },
|
|
1681
|
+
* { tx }
|
|
1682
|
+
* );
|
|
1683
|
+
*
|
|
1684
|
+
* // Create audit log (with transaction)
|
|
1685
|
+
* await this.auditLogs.create({
|
|
1686
|
+
* id: generateUUID(),
|
|
1687
|
+
* entityId: orderId,
|
|
1688
|
+
* action: 'status_change',
|
|
1689
|
+
* oldValue: order.status,
|
|
1690
|
+
* newValue: newStatus,
|
|
1691
|
+
* timestamp: new Date().toISOString()
|
|
1692
|
+
* }, { tx });
|
|
1693
|
+
*
|
|
1694
|
+
* return updatedOrder;
|
|
1695
|
+
* }
|
|
1696
|
+
* ```
|
|
1697
|
+
*/
|
|
1697
1698
|
handler: (tx: PgTransaction<any, any, any>, ...args: T) => Promise<R>;
|
|
1698
1699
|
/**
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1700
|
+
* PostgreSQL transaction configuration options.
|
|
1701
|
+
*
|
|
1702
|
+
* This allows you to customize transaction behavior including:
|
|
1703
|
+
* - **Isolation Level**: Controls visibility of concurrent transaction changes
|
|
1704
|
+
* - **Access Mode**: Whether the transaction is read-only or read-write
|
|
1705
|
+
* - **Deferrable**: For serializable transactions, allows deferring to avoid conflicts
|
|
1706
|
+
*
|
|
1707
|
+
* **Isolation Levels**:
|
|
1708
|
+
* - **read_uncommitted**: Lowest isolation, allows dirty reads (rarely used)
|
|
1709
|
+
* - **read_committed**: Default level, prevents dirty reads
|
|
1710
|
+
* - **repeatable_read**: Prevents dirty and non-repeatable reads
|
|
1711
|
+
* - **serializable**: Highest isolation, full ACID compliance
|
|
1712
|
+
*
|
|
1713
|
+
* **Access Modes**:
|
|
1714
|
+
* - **read_write**: Default, allows both read and write operations
|
|
1715
|
+
* - **read_only**: Only allows read operations, can provide performance benefits
|
|
1716
|
+
*
|
|
1717
|
+
* **When to Use Different Isolation Levels**:
|
|
1718
|
+
* - **read_committed**: Most common operations, good balance of consistency and performance
|
|
1719
|
+
* - **repeatable_read**: When you need consistent reads throughout the transaction
|
|
1720
|
+
* - **serializable**: Critical financial operations, when absolute consistency is required
|
|
1721
|
+
*
|
|
1722
|
+
* @example
|
|
1723
|
+
* ```ts
|
|
1724
|
+
* config: {
|
|
1725
|
+
* isolationLevel: 'serializable', // Highest consistency for financial operations
|
|
1726
|
+
* accessMode: 'read_write'
|
|
1727
|
+
* }
|
|
1728
|
+
* ```
|
|
1729
|
+
*
|
|
1730
|
+
* @example
|
|
1731
|
+
* ```ts
|
|
1732
|
+
* config: {
|
|
1733
|
+
* isolationLevel: 'read_committed', // Default level for most operations
|
|
1734
|
+
* accessMode: 'read_only' // Performance optimization for read-only operations
|
|
1735
|
+
* }
|
|
1736
|
+
* ```
|
|
1737
|
+
*/
|
|
1737
1738
|
config?: PgTransactionConfig;
|
|
1738
1739
|
}
|
|
1739
1740
|
type TransactionContext = PgTransaction<any, any, any>;
|
|
@@ -1750,8 +1751,8 @@ declare class SqliteModelBuilder extends ModelBuilder {
|
|
|
1750
1751
|
schema: string;
|
|
1751
1752
|
}): void;
|
|
1752
1753
|
/**
|
|
1753
|
-
|
|
1754
|
-
|
|
1754
|
+
* Get SQLite-specific config builder for the table.
|
|
1755
|
+
*/
|
|
1755
1756
|
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildColumns<string, any, "sqlite">) => any) | undefined;
|
|
1756
1757
|
schemaToSqliteColumns: <T extends TObject>(tableName: string, schema: T, enums: Map<string, unknown>, tables: Map<string, unknown>) => SchemaToSqliteBuilder<T>;
|
|
1757
1758
|
mapFieldToSqliteColumn: (tableName: string, fieldName: string, value: TSchema, enums: Map<string, any>) => pg$1.SQLiteIntegerBuilderInitial<string> | pg$1.SQLiteNumericBuilderInitial<string> | pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
@@ -1938,7 +1939,7 @@ interface D1ExecResult {
|
|
|
1938
1939
|
*/
|
|
1939
1940
|
declare class CloudflareD1Provider extends DatabaseProvider {
|
|
1940
1941
|
protected readonly kit: DrizzleKitProvider;
|
|
1941
|
-
protected readonly log:
|
|
1942
|
+
protected readonly log: alepha_logger4.Logger;
|
|
1942
1943
|
protected readonly builder: SqliteModelBuilder;
|
|
1943
1944
|
protected readonly env: {
|
|
1944
1945
|
DATABASE_URL: string;
|
|
@@ -1954,14 +1955,14 @@ declare class CloudflareD1Provider extends DatabaseProvider {
|
|
|
1954
1955
|
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
1955
1956
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1956
1957
|
/**
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1958
|
+
* Override development migration to skip sync (not supported on D1).
|
|
1959
|
+
* D1 requires proper migrations to be applied.
|
|
1960
|
+
*/
|
|
1960
1961
|
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
1961
1962
|
/**
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1963
|
+
* Override test migration to run migrations instead of sync.
|
|
1964
|
+
* D1 doesn't support schema synchronization.
|
|
1965
|
+
*/
|
|
1965
1966
|
protected runTestMigration(): Promise<void>;
|
|
1966
1967
|
}
|
|
1967
1968
|
//#endregion
|
|
@@ -2001,17 +2002,17 @@ declare class PostgresModelBuilder extends ModelBuilder {
|
|
|
2001
2002
|
schema: string;
|
|
2002
2003
|
}): void;
|
|
2003
2004
|
/**
|
|
2004
|
-
|
|
2005
|
-
|
|
2005
|
+
* Get PostgreSQL-specific config builder for the table.
|
|
2006
|
+
*/
|
|
2006
2007
|
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildExtraConfigColumns<string, any, "pg">) => PgTableExtraConfigValue[]) | undefined;
|
|
2007
2008
|
schemaToPgColumns: <T extends TObject>(tableName: string, schema: T, nsp: PgSchema, enums: Map<string, unknown>, tables: Map<string, unknown>) => FromSchema<T>;
|
|
2008
2009
|
mapFieldToColumn: (tableName: string, fieldName: string, value: TSchema, nsp: PgSchema, enums: Map<string, any>) => any;
|
|
2009
2010
|
/**
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2011
|
+
* Map a string to a PG column.
|
|
2012
|
+
*
|
|
2013
|
+
* @param key The key of the field.
|
|
2014
|
+
* @param value The value of the field.
|
|
2015
|
+
*/
|
|
2015
2016
|
mapStringToColumn: (key: string, value: TSchema) => drizzle_orm_pg_core0.PgUUIDBuilderInitial<string> | drizzle_orm_pg_core0.PgCustomColumnBuilder<{
|
|
2016
2017
|
name: string;
|
|
2017
2018
|
dataType: "custom";
|
|
@@ -2028,16 +2029,16 @@ declare module "alepha" {
|
|
|
2028
2029
|
}
|
|
2029
2030
|
declare const envSchema$1: alepha34.TObject<{
|
|
2030
2031
|
/**
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2032
|
+
* Main configuration for database connection.
|
|
2033
|
+
* Accept a string in the format of a Postgres connection URL.
|
|
2034
|
+
* Example: postgres://user:password@localhost:5432/database
|
|
2035
|
+
* or
|
|
2036
|
+
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
2037
|
+
*/
|
|
2037
2038
|
DATABASE_URL: alepha34.TOptional<alepha34.TString>;
|
|
2038
2039
|
/**
|
|
2039
|
-
|
|
2040
|
-
|
|
2040
|
+
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
2041
|
+
*/
|
|
2041
2042
|
POSTGRES_SCHEMA: alepha34.TOptional<alepha34.TString>;
|
|
2042
2043
|
}>;
|
|
2043
2044
|
/**
|
|
@@ -2059,7 +2060,7 @@ declare const envSchema$1: alepha34.TObject<{
|
|
|
2059
2060
|
* ```
|
|
2060
2061
|
*/
|
|
2061
2062
|
declare class BunPostgresProvider extends DatabaseProvider {
|
|
2062
|
-
protected readonly log:
|
|
2063
|
+
protected readonly log: alepha_logger4.Logger;
|
|
2063
2064
|
protected readonly env: {
|
|
2064
2065
|
DATABASE_URL?: string | undefined;
|
|
2065
2066
|
POSTGRES_SCHEMA?: string | undefined;
|
|
@@ -2071,21 +2072,21 @@ declare class BunPostgresProvider extends DatabaseProvider {
|
|
|
2071
2072
|
readonly dialect = "postgresql";
|
|
2072
2073
|
get name(): string;
|
|
2073
2074
|
/**
|
|
2074
|
-
|
|
2075
|
-
|
|
2075
|
+
* In testing mode, the schema name will be generated and deleted after the test.
|
|
2076
|
+
*/
|
|
2076
2077
|
protected schemaForTesting: string | undefined;
|
|
2077
2078
|
get url(): string;
|
|
2078
2079
|
/**
|
|
2079
|
-
|
|
2080
|
-
|
|
2080
|
+
* Execute a SQL statement.
|
|
2081
|
+
*/
|
|
2081
2082
|
execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2082
2083
|
/**
|
|
2083
|
-
|
|
2084
|
-
|
|
2084
|
+
* Get Postgres schema used by this provider.
|
|
2085
|
+
*/
|
|
2085
2086
|
get schema(): string;
|
|
2086
2087
|
/**
|
|
2087
|
-
|
|
2088
|
-
|
|
2088
|
+
* Get the Drizzle Postgres database instance.
|
|
2089
|
+
*/
|
|
2089
2090
|
get db(): PgDatabase<any>;
|
|
2090
2091
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2091
2092
|
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
@@ -2134,7 +2135,7 @@ declare module "alepha" {
|
|
|
2134
2135
|
*/
|
|
2135
2136
|
declare class BunSqliteProvider extends DatabaseProvider {
|
|
2136
2137
|
protected readonly kit: DrizzleKitProvider;
|
|
2137
|
-
protected readonly log:
|
|
2138
|
+
protected readonly log: alepha_logger4.Logger;
|
|
2138
2139
|
protected readonly env: {
|
|
2139
2140
|
DATABASE_URL?: string | undefined;
|
|
2140
2141
|
};
|
|
@@ -2160,23 +2161,23 @@ declare module "alepha" {
|
|
|
2160
2161
|
}
|
|
2161
2162
|
declare const envSchema: alepha34.TObject<{
|
|
2162
2163
|
/**
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2164
|
+
* Main configuration for database connection.
|
|
2165
|
+
* Accept a string in the format of a Postgres connection URL.
|
|
2166
|
+
* Example: postgres://user:password@localhost:5432/database
|
|
2167
|
+
* or
|
|
2168
|
+
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
2169
|
+
*/
|
|
2169
2170
|
DATABASE_URL: alepha34.TOptional<alepha34.TString>;
|
|
2170
2171
|
/**
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2172
|
+
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
2173
|
+
*
|
|
2174
|
+
* It will monkey patch drizzle tables.
|
|
2175
|
+
*/
|
|
2175
2176
|
POSTGRES_SCHEMA: alepha34.TOptional<alepha34.TString>;
|
|
2176
2177
|
}>;
|
|
2177
2178
|
declare class NodePostgresProvider extends DatabaseProvider {
|
|
2178
2179
|
static readonly SSL_MODES: readonly ["require", "allow", "prefer", "verify-full"];
|
|
2179
|
-
protected readonly log:
|
|
2180
|
+
protected readonly log: alepha_logger4.Logger;
|
|
2180
2181
|
protected readonly env: {
|
|
2181
2182
|
DATABASE_URL?: string | undefined;
|
|
2182
2183
|
POSTGRES_SCHEMA?: string | undefined;
|
|
@@ -2188,21 +2189,21 @@ declare class NodePostgresProvider extends DatabaseProvider {
|
|
|
2188
2189
|
readonly dialect = "postgresql";
|
|
2189
2190
|
get name(): string;
|
|
2190
2191
|
/**
|
|
2191
|
-
|
|
2192
|
-
|
|
2192
|
+
* In testing mode, the schema name will be generated and deleted after the test.
|
|
2193
|
+
*/
|
|
2193
2194
|
protected schemaForTesting: string | undefined;
|
|
2194
2195
|
get url(): string;
|
|
2195
2196
|
/**
|
|
2196
|
-
|
|
2197
|
-
|
|
2197
|
+
* Execute a SQL statement.
|
|
2198
|
+
*/
|
|
2198
2199
|
execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2199
2200
|
/**
|
|
2200
|
-
|
|
2201
|
-
|
|
2201
|
+
* Get Postgres schema used by this provider.
|
|
2202
|
+
*/
|
|
2202
2203
|
get schema(): string;
|
|
2203
2204
|
/**
|
|
2204
|
-
|
|
2205
|
-
|
|
2205
|
+
* Get the Drizzle Postgres database instance.
|
|
2206
|
+
*/
|
|
2206
2207
|
get db(): PostgresJsDatabase;
|
|
2207
2208
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2208
2209
|
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
@@ -2211,8 +2212,8 @@ declare class NodePostgresProvider extends DatabaseProvider {
|
|
|
2211
2212
|
close(): Promise<void>;
|
|
2212
2213
|
protected migrateLock: alepha_lock0.LockPrimitive<() => Promise<void>>;
|
|
2213
2214
|
/**
|
|
2214
|
-
|
|
2215
|
-
|
|
2215
|
+
* Map the DATABASE_URL to postgres client options.
|
|
2216
|
+
*/
|
|
2216
2217
|
protected getClientOptions(): postgres.Options<any>;
|
|
2217
2218
|
protected ssl(url: URL): "require" | "allow" | "prefer" | "verify-full" | undefined;
|
|
2218
2219
|
}
|
|
@@ -2238,7 +2239,7 @@ declare module "alepha" {
|
|
|
2238
2239
|
*/
|
|
2239
2240
|
declare class NodeSqliteProvider extends DatabaseProvider {
|
|
2240
2241
|
protected readonly kit: DrizzleKitProvider;
|
|
2241
|
-
protected readonly log:
|
|
2242
|
+
protected readonly log: alepha_logger4.Logger;
|
|
2242
2243
|
protected readonly env: {
|
|
2243
2244
|
DATABASE_URL?: string | undefined;
|
|
2244
2245
|
};
|
|
@@ -2261,31 +2262,31 @@ declare namespace index_d_exports {
|
|
|
2261
2262
|
declare module "alepha" {
|
|
2262
2263
|
interface Hooks {
|
|
2263
2264
|
/**
|
|
2264
|
-
|
|
2265
|
-
|
|
2265
|
+
* Fires before creating an entity in the repository.
|
|
2266
|
+
*/
|
|
2266
2267
|
"repository:create:before": {
|
|
2267
2268
|
tableName: string;
|
|
2268
2269
|
data: any;
|
|
2269
2270
|
};
|
|
2270
2271
|
/**
|
|
2271
|
-
|
|
2272
|
-
|
|
2272
|
+
* Fires after creating an entity in the repository.
|
|
2273
|
+
*/
|
|
2273
2274
|
"repository:create:after": {
|
|
2274
2275
|
tableName: string;
|
|
2275
2276
|
data: any;
|
|
2276
2277
|
entity: any;
|
|
2277
2278
|
};
|
|
2278
2279
|
/**
|
|
2279
|
-
|
|
2280
|
-
|
|
2280
|
+
* Fires before updating entities in the repository.
|
|
2281
|
+
*/
|
|
2281
2282
|
"repository:update:before": {
|
|
2282
2283
|
tableName: string;
|
|
2283
2284
|
where: any;
|
|
2284
2285
|
data: any;
|
|
2285
2286
|
};
|
|
2286
2287
|
/**
|
|
2287
|
-
|
|
2288
|
-
|
|
2288
|
+
* Fires after updating entities in the repository.
|
|
2289
|
+
*/
|
|
2289
2290
|
"repository:update:after": {
|
|
2290
2291
|
tableName: string;
|
|
2291
2292
|
where: any;
|
|
@@ -2293,30 +2294,30 @@ declare module "alepha" {
|
|
|
2293
2294
|
entities: any[];
|
|
2294
2295
|
};
|
|
2295
2296
|
/**
|
|
2296
|
-
|
|
2297
|
-
|
|
2297
|
+
* Fires before deleting entities from the repository.
|
|
2298
|
+
*/
|
|
2298
2299
|
"repository:delete:before": {
|
|
2299
2300
|
tableName: string;
|
|
2300
2301
|
where: any;
|
|
2301
2302
|
};
|
|
2302
2303
|
/**
|
|
2303
|
-
|
|
2304
|
-
|
|
2304
|
+
* Fires after deleting entities from the repository.
|
|
2305
|
+
*/
|
|
2305
2306
|
"repository:delete:after": {
|
|
2306
2307
|
tableName: string;
|
|
2307
2308
|
where: any;
|
|
2308
2309
|
ids: Array<string | number>;
|
|
2309
2310
|
};
|
|
2310
2311
|
/**
|
|
2311
|
-
|
|
2312
|
-
|
|
2312
|
+
* Fires before reading entities from the repository.
|
|
2313
|
+
*/
|
|
2313
2314
|
"repository:read:before": {
|
|
2314
2315
|
tableName: string;
|
|
2315
2316
|
query: any;
|
|
2316
2317
|
};
|
|
2317
2318
|
/**
|
|
2318
|
-
|
|
2319
|
-
|
|
2319
|
+
* Fires after reading entities from the repository.
|
|
2320
|
+
*/
|
|
2320
2321
|
"repository:read:after": {
|
|
2321
2322
|
tableName: string;
|
|
2322
2323
|
query: any;
|