@rvoh/dream 0.44.6 → 0.44.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/bin/index.js +7 -87
- package/dist/cjs/src/dream/LeftJoinLoadBuilder.js +1 -1
- package/dist/cjs/src/dream/LoadBuilder.js +1 -1
- package/dist/cjs/src/dream/Query.js +46 -1417
- package/dist/cjs/src/dream/QueryDriver/Base.js +311 -0
- package/dist/cjs/src/dream/QueryDriver/Kysely.js +1771 -0
- package/dist/cjs/src/dream/QueryDriver/Postgres.js +6 -0
- package/dist/cjs/src/dream/internal/saveDream.js +4 -17
- package/dist/esm/src/bin/index.js +7 -87
- package/dist/esm/src/dream/LeftJoinLoadBuilder.js +1 -1
- package/dist/esm/src/dream/LoadBuilder.js +1 -1
- package/dist/esm/src/dream/Query.js +46 -1417
- package/dist/esm/src/dream/QueryDriver/Base.js +308 -0
- package/dist/esm/src/dream/QueryDriver/Kysely.js +1768 -0
- package/dist/esm/src/dream/QueryDriver/Postgres.js +3 -0
- package/dist/esm/src/dream/internal/saveDream.js +4 -17
- package/dist/types/src/bin/index.d.ts +0 -2
- package/dist/types/src/dream/Query.d.ts +27 -155
- package/dist/types/src/dream/QueryDriver/Base.d.ts +242 -0
- package/dist/types/src/dream/QueryDriver/Kysely.d.ts +354 -0
- package/dist/types/src/dream/QueryDriver/Postgres.d.ts +4 -0
- package/dist/types/src/dream/internal/executeDatabaseQuery.d.ts +2 -1
- package/dist/types/src/serializer/SerializerRenderer.d.ts +1 -1
- package/dist/types/src/serializer/builders/DreamSerializerBuilder.d.ts +6 -6
- package/dist/types/src/serializer/builders/ObjectSerializerBuilder.d.ts +5 -5
- package/dist/types/src/types/serializer.d.ts +1 -1
- package/dist/types/src/types/serializer.ts +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +19 -19
- package/docs/classes/Dream.html +131 -131
- package/docs/classes/DreamApp.html +4 -4
- package/docs/classes/DreamBin.html +3 -4
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamLogos.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializerBuilder.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/ObjectSerializerBuilder.html +2 -2
- package/docs/classes/Query.html +86 -57
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/DreamSerializer.html +1 -1
- package/docs/functions/ObjectSerializer.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/cloneDeepSafe.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/expandStiClasses.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/groupBy.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/inferSerializersFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/intersection.html +1 -1
- package/docs/functions/isDreamSerializer.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/normalizeUnicode.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/sortObjectByKey.html +1 -1
- package/docs/functions/sortObjectByValue.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/untypedDb.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/BelongsToStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamAppInitOptions.html +2 -2
- package/docs/interfaces/DreamAppOpts.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/OpenapiDescription.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/SerializerRendererOpts.html +2 -2
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DbConnectionType.html +1 -1
- package/docs/types/DbTypes.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamModelSerializerType.html +1 -1
- package/docs/types/DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializable.html +1 -1
- package/docs/types/DreamSerializableArray.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/HasManyStatement.html +1 -1
- package/docs/types/HasOneStatement.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializerCasing.html +1 -1
- package/docs/types/SimpleObjectSerializerType.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModel.html +1 -1
- package/docs/types/ViewModelClass.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class QueryDriverBase {
|
|
4
|
+
query;
|
|
5
|
+
dreamClass;
|
|
6
|
+
dreamInstance;
|
|
7
|
+
dreamTransaction = null;
|
|
8
|
+
connectionOverride;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*
|
|
12
|
+
* stores the Dream models joined in this Query instance
|
|
13
|
+
*/
|
|
14
|
+
innerJoinDreamClasses = Object.freeze([]);
|
|
15
|
+
constructor(query) {
|
|
16
|
+
this.query = query;
|
|
17
|
+
this.dreamInstance = query.dreamInstance;
|
|
18
|
+
this.dreamClass = query.dreamInstance.constructor;
|
|
19
|
+
this.dreamTransaction = query['originalOpts'].transaction || null;
|
|
20
|
+
this.connectionOverride = query['originalOpts'].connection;
|
|
21
|
+
this.innerJoinDreamClasses = Object.freeze(query['originalOpts'].innerJoinDreamClasses || []);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* migrate the database. Must respond to the NODE_ENV value.
|
|
25
|
+
*/
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
27
|
+
static async migrate() {
|
|
28
|
+
throw new Error('override migrate in child class');
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* rollback the database. Must respond to the NODE_ENV value.
|
|
32
|
+
*/
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
34
|
+
static async rollback(_) {
|
|
35
|
+
throw new Error('override rollback in child class');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* create the database. Must respond to the NODE_ENV value.
|
|
39
|
+
*/
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
41
|
+
static async dbCreate() {
|
|
42
|
+
throw new Error('override dbCreate on child class');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* delete the database. Must respond to the NODE_ENV value.
|
|
46
|
+
*/
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
48
|
+
static async dbDrop() {
|
|
49
|
+
throw new Error('override dbDrop on child class');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* This should build a new migration file in the migrations folder
|
|
53
|
+
* of your application. This will then need to be read and run
|
|
54
|
+
* whenever the `migrate` method is called. The filename should
|
|
55
|
+
* contain a timestamp at the front of the filename, so that it
|
|
56
|
+
* is sorted by date in the file tree, and, more importantly, so
|
|
57
|
+
* they can be run in order by your migration runner.
|
|
58
|
+
*/
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
60
|
+
static async generateMigration(migrationName, columnsWithTypes) {
|
|
61
|
+
throw new Error('override generateMigration in child class');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* defines the syncing behavior for dream and psychic,
|
|
65
|
+
* which is run whenever the `sync` command is called.
|
|
66
|
+
* This is an important step, and will be incredibly
|
|
67
|
+
* comlpex to override. You will need to do the following
|
|
68
|
+
* when overriding this method:
|
|
69
|
+
*
|
|
70
|
+
* 1. introspect the db and use it to generate a db.ts file in the
|
|
71
|
+
* same shape as the existing one. Currently, the process for generating
|
|
72
|
+
* this file is extremely complex and messy, and will be difficult
|
|
73
|
+
* to achieve.
|
|
74
|
+
* 2. generate a types/dream.ts file in the same shape as the existing
|
|
75
|
+
* one. This is normally done using `await new SchemaBuilder().build()`,
|
|
76
|
+
* but this will likely need to be overridden to tailor to your custom
|
|
77
|
+
* database engine.
|
|
78
|
+
*/
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
80
|
+
static async sync(_) {
|
|
81
|
+
throw new Error('override sync on child class');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Converts the given dream class into a Kysely query, enabling
|
|
85
|
+
* you to build custom queries using the Kysely API
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* await User.query().toKysely('select').where('email', '=', 'how@yadoin').execute()
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param type - the type of Kysely query builder instance you would like to obtain
|
|
92
|
+
* @returns A Kysely query. Depending on the type passed, it will return either a SelectQueryBuilder, DeleteQueryBuilder, or an UpdateQueryBuilder
|
|
93
|
+
*/
|
|
94
|
+
toKysely(type) {
|
|
95
|
+
throw new Error('implement toKysely in child class (if it makes sense)');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
*
|
|
100
|
+
* This method is used internally by a Query driver to
|
|
101
|
+
* take the result of a single row in a database, and
|
|
102
|
+
* turn that row into the provided dream instance.
|
|
103
|
+
*
|
|
104
|
+
* If needed, the return type can be overriden to
|
|
105
|
+
* explicitly define the resulting dream instance,
|
|
106
|
+
* in cases where a proper type for the dream class
|
|
107
|
+
* cannot be inferred, i.e.
|
|
108
|
+
*
|
|
109
|
+
* ```ts
|
|
110
|
+
* this.dbResultToDreamInstance<typeof Dream, DreamInstance>(result, this.dreamClass)
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
dbResultToDreamInstance(
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
115
|
+
result,
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
117
|
+
dreamClass) {
|
|
118
|
+
throw new Error('Implement this in your child driver class');
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @internal
|
|
122
|
+
*
|
|
123
|
+
* Used for applying first and last queries
|
|
124
|
+
*
|
|
125
|
+
* @returns A dream instance or null
|
|
126
|
+
*/
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
128
|
+
async takeOne() {
|
|
129
|
+
throw new Error('implement takeOne in child class');
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves an array containing all records matching the Query.
|
|
133
|
+
* Be careful using this, since it will attempt to pull every
|
|
134
|
+
* record into memory at once. When querying might return a large
|
|
135
|
+
* number of records, consider using `.findEach`, which will pull
|
|
136
|
+
* the records in batches.
|
|
137
|
+
*
|
|
138
|
+
* ```ts
|
|
139
|
+
* await User.query().all()
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @returns an array of dreams
|
|
143
|
+
*/
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
145
|
+
async takeAll(
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
147
|
+
options = {}) {
|
|
148
|
+
throw new Error('implement takeAll in child class');
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Retrieves the max value of the specified column
|
|
152
|
+
* for this Query
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* await User.query().max('id')
|
|
156
|
+
* // 99
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @param columnName - a column name on the model
|
|
160
|
+
* @returns the max value of the specified column for this Query
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
164
|
+
async max(columnName) {
|
|
165
|
+
throw new Error('implement max in child class');
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Retrieves the min value of the specified column
|
|
169
|
+
* for this Query
|
|
170
|
+
*
|
|
171
|
+
* ```ts
|
|
172
|
+
* await User.query().min('id')
|
|
173
|
+
* // 1
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @param columnName - a column name on the model
|
|
177
|
+
* @returns the min value of the specified column for this Query
|
|
178
|
+
*/
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
180
|
+
async min(columnName) {
|
|
181
|
+
throw new Error('implement min in child class');
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Retrieves the number of records in the database
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* await User.query().count()
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @returns The number of records in the database
|
|
191
|
+
*/
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
193
|
+
async count() {
|
|
194
|
+
throw new Error('implement count in child class');
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* @internal
|
|
198
|
+
*
|
|
199
|
+
* Runs the query and extracts plucked values
|
|
200
|
+
*
|
|
201
|
+
* @returns An array of plucked values
|
|
202
|
+
*/
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
204
|
+
async pluck(...fields) {
|
|
205
|
+
throw new Error('implement pluck in child class');
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Returns a new Kysely SelectQueryBuilder instance to be used
|
|
209
|
+
* in a sub Query
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* const records = await User.where({
|
|
213
|
+
* id: Post.query().nestedSelect('userId'),
|
|
214
|
+
* }).all()
|
|
215
|
+
* // [User{id: 1}, ...]
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @param selection - the column to use for your nested Query
|
|
219
|
+
* @returns A Kysely SelectQueryBuilder instance
|
|
220
|
+
*/
|
|
221
|
+
nestedSelect(
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
223
|
+
selection) {
|
|
224
|
+
throw new Error('implement nestedSelect in child class');
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* executes provided query instance as a deletion query.
|
|
228
|
+
* @returns the number of deleted rows
|
|
229
|
+
*/
|
|
230
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
231
|
+
async delete() {
|
|
232
|
+
throw new Error('implement delete in child class');
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* executes provided query instance as an update query.
|
|
236
|
+
* @returns the number of updated rows
|
|
237
|
+
*/
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
239
|
+
async update(attributes) {
|
|
240
|
+
throw new Error('implement update in child class');
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* persists any unsaved changes to the database. If a transaction
|
|
244
|
+
* is provided as a second argument, it will use that transaction
|
|
245
|
+
* to encapsulate the persisting of the dream, as well as any
|
|
246
|
+
* subsequent model hooks that are fired.
|
|
247
|
+
*/
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
249
|
+
static async saveDream(dream, txn = null) {
|
|
250
|
+
throw new Error('implement saveDream in child class');
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Returns the sql that would be executed by this Query
|
|
254
|
+
*
|
|
255
|
+
* ```ts
|
|
256
|
+
* User.where({ email: 'how@yadoin' }).sql()
|
|
257
|
+
* // {
|
|
258
|
+
* // query: {
|
|
259
|
+
* // kind: 'SelectQueryNode',
|
|
260
|
+
* // from: { kind: 'FromNode', froms: [Array] },
|
|
261
|
+
* // selections: [ [Object] ],
|
|
262
|
+
* // distinctOn: undefined,
|
|
263
|
+
* // joins: undefined,
|
|
264
|
+
* // groupBy: undefined,
|
|
265
|
+
* // orderBy: undefined,
|
|
266
|
+
* // where: { kind: 'WhereNode', where: [Object] },
|
|
267
|
+
* // frontModifiers: undefined,
|
|
268
|
+
* // endModifiers: undefined,
|
|
269
|
+
* // limit: undefined,
|
|
270
|
+
* // offset: undefined,
|
|
271
|
+
* // with: undefined,
|
|
272
|
+
* // having: undefined,
|
|
273
|
+
* // explain: undefined,
|
|
274
|
+
* // setOperations: undefined
|
|
275
|
+
* // },
|
|
276
|
+
* // sql: 'select "users".* from "users" where ("users"."email" = $1 and "users"."deleted_at" is null)',
|
|
277
|
+
* // parameters: [ 'how@yadoin' ]
|
|
278
|
+
* //}
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* @returns An object representing the underlying sql statement
|
|
282
|
+
*
|
|
283
|
+
*/
|
|
284
|
+
sql() {
|
|
285
|
+
throw new Error('implement sql in child class');
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @internal
|
|
289
|
+
*
|
|
290
|
+
* Used to hydrate dreams with the provided associations
|
|
291
|
+
*/
|
|
292
|
+
hydrateAssociation(
|
|
293
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
294
|
+
dreams,
|
|
295
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
296
|
+
association,
|
|
297
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
298
|
+
preloadedDreamsAndWhatTheyPointTo) {
|
|
299
|
+
throw new Error('define hydrateAssociation on child class');
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* @internal
|
|
303
|
+
*
|
|
304
|
+
* Used by loadBuider
|
|
305
|
+
*/
|
|
306
|
+
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
|
|
307
|
+
async hydratePreload(dream) {
|
|
308
|
+
throw new Error('define hydratePreload on child class');
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.default = QueryDriverBase;
|