@rvoh/dream 2.26.0 → 2.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/Dream.js +0 -17
- package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +0 -18
- package/dist/cjs/src/dream/Query.js +0 -23
- package/dist/cjs/src/dream/QueryDriver/Kysely.js +8 -8
- package/dist/esm/src/Dream.js +0 -17
- package/dist/esm/src/dream/DreamClassTransactionBuilder.js +0 -18
- package/dist/esm/src/dream/Query.js +0 -23
- package/dist/esm/src/dream/QueryDriver/Kysely.js +8 -8
- package/dist/types/src/Dream.d.ts +3 -2
- package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +3 -2
- package/dist/types/src/dream/Query.d.ts +3 -2
- package/dist/types/src/types/associations/shared.d.ts +1 -1
- package/dist/types/src/types/dream.d.ts +3 -0
- package/dist/types/src/types/query.d.ts +1 -1
- package/dist/types/src/types/types/associations/shared.ts +8 -6
- package/dist/types/src/types/types/dream.ts +6 -0
- package/dist/types/src/types/types/query.ts +1 -1
- package/docs/classes/db.DreamMigrationHelpers.html +11 -11
- package/docs/classes/db.KyselyQueryDriver.html +40 -40
- package/docs/classes/db.PostgresQueryDriver.html +41 -41
- package/docs/classes/db.QueryDriverBase.html +39 -39
- package/docs/classes/errors.CheckConstraintViolation.html +3 -3
- package/docs/classes/errors.ColumnOverflow.html +3 -3
- package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
- package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
- package/docs/classes/errors.DecryptionError.html +2 -2
- package/docs/classes/errors.DecryptionParseError.html +2 -2
- package/docs/classes/errors.DecryptionRotationError.html +3 -3
- package/docs/classes/errors.GlobalNameNotSet.html +3 -3
- package/docs/classes/errors.InvalidCalendarDate.html +2 -2
- package/docs/classes/errors.InvalidClockTime.html +2 -2
- package/docs/classes/errors.InvalidClockTimeTz.html +2 -2
- package/docs/classes/errors.InvalidDateTime.html +2 -2
- package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
- package/docs/classes/errors.NonLoadedAssociation.html +3 -3
- package/docs/classes/errors.NotNullViolation.html +3 -3
- package/docs/classes/errors.RecordNotFound.html +3 -3
- package/docs/classes/errors.ValidationError.html +3 -3
- package/docs/classes/index.CalendarDate.html +33 -33
- package/docs/classes/index.ClockTime.html +32 -32
- package/docs/classes/index.ClockTimeTz.html +35 -35
- package/docs/classes/index.DateTime.html +86 -86
- package/docs/classes/index.Decorators.html +19 -19
- package/docs/classes/index.Dream.html +132 -124
- package/docs/classes/index.DreamApp.html +10 -10
- package/docs/classes/index.DreamTransaction.html +2 -2
- package/docs/classes/index.Env.html +2 -2
- package/docs/classes/index.Query.html +93 -80
- package/docs/classes/system.CliFileWriter.html +4 -4
- package/docs/classes/system.DreamBin.html +2 -2
- package/docs/classes/system.DreamCLI.html +7 -7
- package/docs/classes/system.DreamImporter.html +2 -2
- package/docs/classes/system.DreamLogos.html +2 -2
- package/docs/classes/system.DreamSerializerBuilder.html +11 -11
- package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
- package/docs/classes/system.PathHelpers.html +3 -3
- package/docs/classes/utils.Encrypt.html +3 -3
- package/docs/classes/utils.Range.html +2 -2
- package/docs/functions/db.closeAllDbConnections.html +1 -1
- package/docs/functions/db.dreamDbConnections.html +1 -1
- package/docs/functions/db.untypedDb.html +1 -1
- package/docs/functions/db.validateColumn.html +1 -1
- package/docs/functions/db.validateTable.html +1 -1
- package/docs/functions/errors.pgErrorType.html +1 -1
- package/docs/functions/index.DreamSerializer.html +1 -1
- package/docs/functions/index.ObjectSerializer.html +1 -1
- package/docs/functions/index.ReplicaSafe.html +1 -1
- package/docs/functions/index.STI.html +1 -1
- package/docs/functions/index.SoftDelete.html +1 -1
- package/docs/functions/utils.camelize.html +1 -1
- package/docs/functions/utils.capitalize.html +1 -1
- package/docs/functions/utils.cloneDeepSafe.html +1 -1
- package/docs/functions/utils.compact.html +1 -1
- package/docs/functions/utils.groupBy.html +1 -1
- package/docs/functions/utils.hyphenize.html +1 -1
- package/docs/functions/utils.intersection.html +1 -1
- package/docs/functions/utils.isEmpty.html +1 -1
- package/docs/functions/utils.normalizeUnicode.html +1 -1
- package/docs/functions/utils.pascalize.html +1 -1
- package/docs/functions/utils.percent.html +1 -1
- package/docs/functions/utils.range.html +1 -1
- package/docs/functions/utils.round.html +1 -1
- package/docs/functions/utils.sanitizeString.html +1 -1
- package/docs/functions/utils.snakeify.html +1 -1
- package/docs/functions/utils.sort.html +1 -1
- package/docs/functions/utils.sortBy.html +1 -1
- package/docs/functions/utils.sortObjectByKey.html +1 -1
- package/docs/functions/utils.sortObjectByValue.html +1 -1
- package/docs/functions/utils.uncapitalize.html +1 -1
- package/docs/functions/utils.uniq.html +1 -1
- package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
- package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/types.BelongsToStatement.html +2 -2
- package/docs/interfaces/types.DecoratorContext.html +2 -2
- package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
- package/docs/interfaces/types.DreamAppOpts.html +2 -2
- package/docs/interfaces/types.DreamDbConfig.html +5 -5
- package/docs/interfaces/types.DurationObject.html +2 -2
- package/docs/interfaces/types.EncryptOptions.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
- package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/openapi.OpenapiAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiFormats.html +1 -1
- package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaExpressionRef.html +2 -2
- package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +2 -2
- package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNull.html +2 -2
- package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaString.html +1 -1
- package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiTypeField.html +1 -1
- package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
- package/docs/types/types.CalendarDateDurationUnit.html +1 -1
- package/docs/types/types.CalendarDateObject.html +1 -1
- package/docs/types/types.Camelized.html +1 -1
- package/docs/types/types.ClockTimeObject.html +1 -1
- package/docs/types/types.DbConnectionType.html +1 -1
- package/docs/types/types.DbTypes.html +1 -1
- package/docs/types/types.DreamAssociationMetadata.html +1 -1
- package/docs/types/types.DreamAttributes.html +1 -1
- package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
- package/docs/types/types.DreamClassColumn.html +1 -1
- package/docs/types/types.DreamColumn.html +1 -1
- package/docs/types/types.DreamColumnNames.html +1 -1
- package/docs/types/types.DreamLogLevel.html +1 -1
- package/docs/types/types.DreamLogger.html +2 -2
- package/docs/types/types.DreamModelSerializerType.html +1 -1
- package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/types.DreamParamSafeAttributes.html +1 -1
- package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
- package/docs/types/types.DreamSerializable.html +1 -1
- package/docs/types/types.DreamSerializableArray.html +1 -1
- package/docs/types/types.DreamSerializerKey.html +1 -1
- package/docs/types/types.DreamSerializers.html +1 -1
- package/docs/types/types.DreamVirtualColumns.html +1 -1
- package/docs/types/types.DurationUnit.html +1 -1
- package/docs/types/types.EncryptAlgorithm.html +1 -1
- package/docs/types/types.HasManyStatement.html +1 -1
- package/docs/types/types.HasOneStatement.html +1 -1
- package/docs/types/types.Hyphenized.html +1 -1
- package/docs/types/types.Pascalized.html +1 -1
- package/docs/types/types.PrimaryKeyType.html +1 -1
- package/docs/types/types.RoundingPrecision.html +1 -1
- package/docs/types/types.SerializerCasing.html +1 -1
- package/docs/types/types.SimpleObjectSerializerType.html +1 -1
- package/docs/types/types.Snakeified.html +1 -1
- package/docs/types/types.StrictInterface.html +1 -1
- package/docs/types/types.UpdateableAssociationProperties.html +1 -1
- package/docs/types/types.UpdateableProperties.html +1 -1
- package/docs/types/types.ValidationType.html +1 -1
- package/docs/types/types.ViewModel.html +2 -2
- package/docs/types/types.ViewModelClass.html +1 -1
- package/docs/types/types.WeekdayName.html +1 -1
- package/docs/types/types.WhereStatementForDream.html +1 -1
- package/docs/types/types.WhereStatementForDreamClass.html +1 -1
- package/docs/variables/index.DreamConst.html +1 -1
- package/docs/variables/index.ops.html +1 -1
- package/docs/variables/openapi.openapiPrimitiveTypes.html +1 -1
- package/docs/variables/openapi.openapiShorthandPrimitiveTypes.html +1 -1
- package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
- package/docs/variables/system.primaryKeyTypes.html +1 -1
- package/package.json +1 -1
package/dist/cjs/src/Dream.js
CHANGED
|
@@ -1787,23 +1787,6 @@ export default class Dream {
|
|
|
1787
1787
|
static async pluck(...columnNames) {
|
|
1788
1788
|
return (await this.query().pluck(...columnNames));
|
|
1789
1789
|
}
|
|
1790
|
-
/**
|
|
1791
|
-
* Plucks the specified fields from the given dream class table
|
|
1792
|
-
* in batches, passing each found columns into the
|
|
1793
|
-
* provided callback function
|
|
1794
|
-
*
|
|
1795
|
-
* ```ts
|
|
1796
|
-
* await User.order('id').pluckEach('id', (id) => {
|
|
1797
|
-
* console.log(id)
|
|
1798
|
-
* })
|
|
1799
|
-
* // 1
|
|
1800
|
-
* // 2
|
|
1801
|
-
* // 3
|
|
1802
|
-
* ```
|
|
1803
|
-
*
|
|
1804
|
-
* @param args - a list of fields to pluck, followed by a callback function to call for each set of found fields
|
|
1805
|
-
* @returns void
|
|
1806
|
-
*/
|
|
1807
1790
|
static async pluckEach(...args) {
|
|
1808
1791
|
return await this.query().pluckEach(...args);
|
|
1809
1792
|
}
|
|
@@ -747,24 +747,6 @@ export default class DreamClassTransactionBuilder {
|
|
|
747
747
|
async pluck(...columnNames) {
|
|
748
748
|
return (await this.queryInstance().pluck(...columnNames));
|
|
749
749
|
}
|
|
750
|
-
/**
|
|
751
|
-
* Plucks the specified fields from the given dream class table
|
|
752
|
-
* in batches, passing each found columns into the provided callback function.
|
|
753
|
-
*
|
|
754
|
-
* ```ts
|
|
755
|
-
* await ApplicationModel.transaction(async txn => {
|
|
756
|
-
* await User.txn(txn).order('id').pluckEach('id', (id) => {
|
|
757
|
-
* console.log(id)
|
|
758
|
-
* })
|
|
759
|
-
* // 1
|
|
760
|
-
* // 2
|
|
761
|
-
* // 3
|
|
762
|
-
* })
|
|
763
|
-
* ```
|
|
764
|
-
*
|
|
765
|
-
* @param fields - A list of fields to pluck, followed by a callback function to call for each set of found fields
|
|
766
|
-
* @returns void
|
|
767
|
-
*/
|
|
768
750
|
async pluckEach(...args) {
|
|
769
751
|
await this.queryInstance().pluckEach(...args);
|
|
770
752
|
}
|
|
@@ -1338,29 +1338,6 @@ export default class Query {
|
|
|
1338
1338
|
const vals = await this.dbDriverInstance().pluck(...columnNames);
|
|
1339
1339
|
return (columnNames.length > 1 ? vals : vals.flat());
|
|
1340
1340
|
}
|
|
1341
|
-
/**
|
|
1342
|
-
* Plucks the specified column names from the given dream class table
|
|
1343
|
-
* in batches, passing each found columns into the
|
|
1344
|
-
* provided callback function
|
|
1345
|
-
*
|
|
1346
|
-
* ```ts
|
|
1347
|
-
* await User.order('id').pluckEach('id', (id) => {
|
|
1348
|
-
* console.log(id)
|
|
1349
|
-
* })
|
|
1350
|
-
* // 1
|
|
1351
|
-
* // 2
|
|
1352
|
-
* // 3
|
|
1353
|
-
* ```
|
|
1354
|
-
*
|
|
1355
|
-
* A `limit` or `offset` on the Query cannot compose with the batch windows
|
|
1356
|
-
* — each window replaces the limit with the batch size and the offset with
|
|
1357
|
-
* the running window offset, silently ignoring both — so a limit- or
|
|
1358
|
-
* offset-carrying Query throws at runtime.
|
|
1359
|
-
*
|
|
1360
|
-
* @param args - a list of column names to pluck, followed by a callback function to call for each set of found fields
|
|
1361
|
-
* @returns void
|
|
1362
|
-
* @throws BatchingIncompatibleWithLimitOrOffset if the query carries a `limit` or `offset`
|
|
1363
|
-
*/
|
|
1364
1341
|
async pluckEach(...args) {
|
|
1365
1342
|
const providedCbIndex = args.findIndex(v => typeof v === 'function');
|
|
1366
1343
|
const providedCb = args[providedCbIndex];
|
|
@@ -457,7 +457,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
457
457
|
bypassSelectAll: true,
|
|
458
458
|
bypassOrder: true,
|
|
459
459
|
});
|
|
460
|
-
kyselyQuery = kyselyQuery.select(max(columnName));
|
|
460
|
+
kyselyQuery = kyselyQuery.select(max(this.namespaceColumn(columnName)));
|
|
461
461
|
const data = await executeDatabaseQuery(kyselyQuery, 'executeTakeFirstOrThrow');
|
|
462
462
|
return data.max;
|
|
463
463
|
}
|
|
@@ -477,7 +477,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
477
477
|
async maxBy(groupColumn, aggregatedColumn) {
|
|
478
478
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
479
479
|
const { max } = this.dbFor('select').fn;
|
|
480
|
-
return this.groupedAggregate(groupColumn, max(aggregatedColumn));
|
|
480
|
+
return this.groupedAggregate(groupColumn, max(this.namespaceColumn(aggregatedColumn)));
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
483
483
|
* Retrieves the min value of the specified column
|
|
@@ -498,7 +498,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
498
498
|
bypassSelectAll: true,
|
|
499
499
|
bypassOrder: true,
|
|
500
500
|
});
|
|
501
|
-
kyselyQuery = kyselyQuery.select(min(columnName));
|
|
501
|
+
kyselyQuery = kyselyQuery.select(min(this.namespaceColumn(columnName)));
|
|
502
502
|
const data = await executeDatabaseQuery(kyselyQuery, 'executeTakeFirstOrThrow');
|
|
503
503
|
return data.min;
|
|
504
504
|
}
|
|
@@ -518,7 +518,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
518
518
|
async minBy(groupColumn, aggregatedColumn) {
|
|
519
519
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
520
520
|
const { min } = this.dbFor('select').fn;
|
|
521
|
-
return this.groupedAggregate(groupColumn, min(aggregatedColumn));
|
|
521
|
+
return this.groupedAggregate(groupColumn, min(this.namespaceColumn(aggregatedColumn)));
|
|
522
522
|
}
|
|
523
523
|
/**
|
|
524
524
|
* Retrieves the sum value of the specified column
|
|
@@ -539,7 +539,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
539
539
|
bypassSelectAll: true,
|
|
540
540
|
bypassOrder: true,
|
|
541
541
|
});
|
|
542
|
-
kyselyQuery = kyselyQuery.select(sum(columnName));
|
|
542
|
+
kyselyQuery = kyselyQuery.select(sum(this.namespaceColumn(columnName)));
|
|
543
543
|
const data = await executeDatabaseQuery(kyselyQuery, 'executeTakeFirstOrThrow');
|
|
544
544
|
return data.sum === null ? null : parseFloat(data.sum);
|
|
545
545
|
}
|
|
@@ -559,7 +559,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
559
559
|
async sumBy(groupColumn, aggregatedColumn) {
|
|
560
560
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
561
561
|
const { sum } = this.dbFor('select').fn;
|
|
562
|
-
return this.groupedAggregate(groupColumn, sum(aggregatedColumn), rawSum => rawSum === null ? null : parseFloat(rawSum));
|
|
562
|
+
return this.groupedAggregate(groupColumn, sum(this.namespaceColumn(aggregatedColumn)), rawSum => rawSum === null ? null : parseFloat(rawSum));
|
|
563
563
|
}
|
|
564
564
|
/**
|
|
565
565
|
* Retrieves the average value of the specified column
|
|
@@ -580,7 +580,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
580
580
|
bypassSelectAll: true,
|
|
581
581
|
bypassOrder: true,
|
|
582
582
|
});
|
|
583
|
-
kyselyQuery = kyselyQuery.select(avg(columnName));
|
|
583
|
+
kyselyQuery = kyselyQuery.select(avg(this.namespaceColumn(columnName)));
|
|
584
584
|
const data = await executeDatabaseQuery(kyselyQuery, 'executeTakeFirstOrThrow');
|
|
585
585
|
return data.avg;
|
|
586
586
|
}
|
|
@@ -600,7 +600,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
600
600
|
async avgBy(groupColumn, aggregatedColumn) {
|
|
601
601
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
602
602
|
const { avg } = this.dbFor('select').fn;
|
|
603
|
-
return this.groupedAggregate(groupColumn, avg(aggregatedColumn));
|
|
603
|
+
return this.groupedAggregate(groupColumn, avg(this.namespaceColumn(aggregatedColumn)));
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* Retrieves the number of records in the database
|
package/dist/esm/src/Dream.js
CHANGED
|
@@ -1787,23 +1787,6 @@ export default class Dream {
|
|
|
1787
1787
|
static async pluck(...columnNames) {
|
|
1788
1788
|
return (await this.query().pluck(...columnNames));
|
|
1789
1789
|
}
|
|
1790
|
-
/**
|
|
1791
|
-
* Plucks the specified fields from the given dream class table
|
|
1792
|
-
* in batches, passing each found columns into the
|
|
1793
|
-
* provided callback function
|
|
1794
|
-
*
|
|
1795
|
-
* ```ts
|
|
1796
|
-
* await User.order('id').pluckEach('id', (id) => {
|
|
1797
|
-
* console.log(id)
|
|
1798
|
-
* })
|
|
1799
|
-
* // 1
|
|
1800
|
-
* // 2
|
|
1801
|
-
* // 3
|
|
1802
|
-
* ```
|
|
1803
|
-
*
|
|
1804
|
-
* @param args - a list of fields to pluck, followed by a callback function to call for each set of found fields
|
|
1805
|
-
* @returns void
|
|
1806
|
-
*/
|
|
1807
1790
|
static async pluckEach(...args) {
|
|
1808
1791
|
return await this.query().pluckEach(...args);
|
|
1809
1792
|
}
|
|
@@ -747,24 +747,6 @@ export default class DreamClassTransactionBuilder {
|
|
|
747
747
|
async pluck(...columnNames) {
|
|
748
748
|
return (await this.queryInstance().pluck(...columnNames));
|
|
749
749
|
}
|
|
750
|
-
/**
|
|
751
|
-
* Plucks the specified fields from the given dream class table
|
|
752
|
-
* in batches, passing each found columns into the provided callback function.
|
|
753
|
-
*
|
|
754
|
-
* ```ts
|
|
755
|
-
* await ApplicationModel.transaction(async txn => {
|
|
756
|
-
* await User.txn(txn).order('id').pluckEach('id', (id) => {
|
|
757
|
-
* console.log(id)
|
|
758
|
-
* })
|
|
759
|
-
* // 1
|
|
760
|
-
* // 2
|
|
761
|
-
* // 3
|
|
762
|
-
* })
|
|
763
|
-
* ```
|
|
764
|
-
*
|
|
765
|
-
* @param fields - A list of fields to pluck, followed by a callback function to call for each set of found fields
|
|
766
|
-
* @returns void
|
|
767
|
-
*/
|
|
768
750
|
async pluckEach(...args) {
|
|
769
751
|
await this.queryInstance().pluckEach(...args);
|
|
770
752
|
}
|
|
@@ -1338,29 +1338,6 @@ export default class Query {
|
|
|
1338
1338
|
const vals = await this.dbDriverInstance().pluck(...columnNames);
|
|
1339
1339
|
return (columnNames.length > 1 ? vals : vals.flat());
|
|
1340
1340
|
}
|
|
1341
|
-
/**
|
|
1342
|
-
* Plucks the specified column names from the given dream class table
|
|
1343
|
-
* in batches, passing each found columns into the
|
|
1344
|
-
* provided callback function
|
|
1345
|
-
*
|
|
1346
|
-
* ```ts
|
|
1347
|
-
* await User.order('id').pluckEach('id', (id) => {
|
|
1348
|
-
* console.log(id)
|
|
1349
|
-
* })
|
|
1350
|
-
* // 1
|
|
1351
|
-
* // 2
|
|
1352
|
-
* // 3
|
|
1353
|
-
* ```
|
|
1354
|
-
*
|
|
1355
|
-
* A `limit` or `offset` on the Query cannot compose with the batch windows
|
|
1356
|
-
* — each window replaces the limit with the batch size and the offset with
|
|
1357
|
-
* the running window offset, silently ignoring both — so a limit- or
|
|
1358
|
-
* offset-carrying Query throws at runtime.
|
|
1359
|
-
*
|
|
1360
|
-
* @param args - a list of column names to pluck, followed by a callback function to call for each set of found fields
|
|
1361
|
-
* @returns void
|
|
1362
|
-
* @throws BatchingIncompatibleWithLimitOrOffset if the query carries a `limit` or `offset`
|
|
1363
|
-
*/
|
|
1364
1341
|
async pluckEach(...args) {
|
|
1365
1342
|
const providedCbIndex = args.findIndex(v => typeof v === 'function');
|
|
1366
1343
|
const providedCb = args[providedCbIndex];
|
|
@@ -457,7 +457,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
457
457
|
bypassSelectAll: true,
|
|
458
458
|
bypassOrder: true,
|
|
459
459
|
});
|
|
460
|
-
kyselyQuery = kyselyQuery.select(max(columnName));
|
|
460
|
+
kyselyQuery = kyselyQuery.select(max(this.namespaceColumn(columnName)));
|
|
461
461
|
const data = await executeDatabaseQuery(kyselyQuery, 'executeTakeFirstOrThrow');
|
|
462
462
|
return data.max;
|
|
463
463
|
}
|
|
@@ -477,7 +477,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
477
477
|
async maxBy(groupColumn, aggregatedColumn) {
|
|
478
478
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
479
479
|
const { max } = this.dbFor('select').fn;
|
|
480
|
-
return this.groupedAggregate(groupColumn, max(aggregatedColumn));
|
|
480
|
+
return this.groupedAggregate(groupColumn, max(this.namespaceColumn(aggregatedColumn)));
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
483
483
|
* Retrieves the min value of the specified column
|
|
@@ -498,7 +498,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
498
498
|
bypassSelectAll: true,
|
|
499
499
|
bypassOrder: true,
|
|
500
500
|
});
|
|
501
|
-
kyselyQuery = kyselyQuery.select(min(columnName));
|
|
501
|
+
kyselyQuery = kyselyQuery.select(min(this.namespaceColumn(columnName)));
|
|
502
502
|
const data = await executeDatabaseQuery(kyselyQuery, 'executeTakeFirstOrThrow');
|
|
503
503
|
return data.min;
|
|
504
504
|
}
|
|
@@ -518,7 +518,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
518
518
|
async minBy(groupColumn, aggregatedColumn) {
|
|
519
519
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
520
520
|
const { min } = this.dbFor('select').fn;
|
|
521
|
-
return this.groupedAggregate(groupColumn, min(aggregatedColumn));
|
|
521
|
+
return this.groupedAggregate(groupColumn, min(this.namespaceColumn(aggregatedColumn)));
|
|
522
522
|
}
|
|
523
523
|
/**
|
|
524
524
|
* Retrieves the sum value of the specified column
|
|
@@ -539,7 +539,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
539
539
|
bypassSelectAll: true,
|
|
540
540
|
bypassOrder: true,
|
|
541
541
|
});
|
|
542
|
-
kyselyQuery = kyselyQuery.select(sum(columnName));
|
|
542
|
+
kyselyQuery = kyselyQuery.select(sum(this.namespaceColumn(columnName)));
|
|
543
543
|
const data = await executeDatabaseQuery(kyselyQuery, 'executeTakeFirstOrThrow');
|
|
544
544
|
return data.sum === null ? null : parseFloat(data.sum);
|
|
545
545
|
}
|
|
@@ -559,7 +559,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
559
559
|
async sumBy(groupColumn, aggregatedColumn) {
|
|
560
560
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
561
561
|
const { sum } = this.dbFor('select').fn;
|
|
562
|
-
return this.groupedAggregate(groupColumn, sum(aggregatedColumn), rawSum => rawSum === null ? null : parseFloat(rawSum));
|
|
562
|
+
return this.groupedAggregate(groupColumn, sum(this.namespaceColumn(aggregatedColumn)), rawSum => rawSum === null ? null : parseFloat(rawSum));
|
|
563
563
|
}
|
|
564
564
|
/**
|
|
565
565
|
* Retrieves the average value of the specified column
|
|
@@ -580,7 +580,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
580
580
|
bypassSelectAll: true,
|
|
581
581
|
bypassOrder: true,
|
|
582
582
|
});
|
|
583
|
-
kyselyQuery = kyselyQuery.select(avg(columnName));
|
|
583
|
+
kyselyQuery = kyselyQuery.select(avg(this.namespaceColumn(columnName)));
|
|
584
584
|
const data = await executeDatabaseQuery(kyselyQuery, 'executeTakeFirstOrThrow');
|
|
585
585
|
return data.avg;
|
|
586
586
|
}
|
|
@@ -600,7 +600,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
600
600
|
async avgBy(groupColumn, aggregatedColumn) {
|
|
601
601
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
602
602
|
const { avg } = this.dbFor('select').fn;
|
|
603
|
-
return this.groupedAggregate(groupColumn, avg(aggregatedColumn));
|
|
603
|
+
return this.groupedAggregate(groupColumn, avg(this.namespaceColumn(aggregatedColumn)));
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* Retrieves the number of records in the database
|
|
@@ -8,7 +8,7 @@ import LoadBuilder from './dream/LoadBuilder.js';
|
|
|
8
8
|
import Query from './dream/Query.js';
|
|
9
9
|
import { OnStatementForSpecificColumns, PassthroughOnClause, WhereStatement } from './types/associations/shared.js';
|
|
10
10
|
import { AssociationTableNames, DbConnectionType } from './types/db.js';
|
|
11
|
-
import { AllDefaultScopeNames, AssociationNameToDream, AttributeKeys, CreateOrFindByExtraOpts, DefaultOrNamedScopeName, DreamAssociationNames, DreamAssociationNamesWithoutRequiredOnClauses, DreamAssociationNamesWithPassthroughOnClauses, DreamAssociationNamesWithRequiredOnClauses, DreamAttributes, DreamBelongsToAssociationNames, DreamColumnNames, DreamHasManyAssociationNames, DreamHasOneAssociationNames, DreamModelAssociationNames, DreamPrimaryKeyType, DreamSerializerKey, FindablePropertiesForClass, GlobalModelNames, GlobalSerializerName, JoinAndStatements, OrderDir, PassthroughColumnNames, PassthroughOnClauseKeys, PluckEachArgs, PrimaryKeyForFind, RequiredOnClauseKeys, TableColumnNames, UpdateableAssociationProperties, UpdateableProperties, UpdateablePropertiesForClass, UpdateOrCreateByExtraOpts } from './types/dream.js';
|
|
11
|
+
import { AllDefaultScopeNames, AssociationNameToDream, AttributeKeys, CreateOrFindByExtraOpts, DefaultOrNamedScopeName, DreamAssociationNames, DreamAssociationNamesWithoutRequiredOnClauses, DreamAssociationNamesWithPassthroughOnClauses, DreamAssociationNamesWithRequiredOnClauses, DreamAttributes, DreamBelongsToAssociationNames, DreamColumnNames, DreamHasManyAssociationNames, DreamHasOneAssociationNames, DreamModelAssociationNames, DreamPrimaryKeyType, DreamSerializerKey, FindablePropertiesForClass, GlobalModelNames, GlobalSerializerName, JoinAndStatements, OrderDir, PassthroughColumnNames, PassthroughOnClauseKeys, PluckEachArgs, PrimaryKeyForFind, RequiredOnClauseKeys, TableColumnNames, UpdateableAssociationProperties, UpdateableProperties, UpdateablePropertiesForClass, UpdateOrCreateByExtraOpts, ValidatedPluckEachColumnNames } from './types/dream.js';
|
|
12
12
|
import { BaseModelColumnTypes, CursorPaginatedDreamQueryOptions, CursorPaginatedDreamQueryResult, DefaultQueryTypeOptions, FindEachOpts, LoadForModifierFn, PaginatedDreamQueryOptions, PaginatedDreamQueryResult, QueryWithJoinedAssociationsType, QueryWithJoinedAssociationsTypeAndNoPreload } from './types/query.js';
|
|
13
13
|
import { DreamModelSerializerType, SimpleObjectSerializerType } from './types/serializer.js';
|
|
14
14
|
import { ValidationType } from './types/validation.js';
|
|
@@ -1445,7 +1445,8 @@ export default class Dream {
|
|
|
1445
1445
|
* @param args - a list of fields to pluck, followed by a callback function to call for each set of found fields
|
|
1446
1446
|
* @returns void
|
|
1447
1447
|
*/
|
|
1448
|
-
static pluckEach<T extends typeof Dream, I extends InstanceType<T>, ColumnNames extends TableColumnNames<I['DB'], I['table']
|
|
1448
|
+
static pluckEach<T extends typeof Dream, I extends InstanceType<T>, const ColumnNames extends unknown[]>(this: T, ...args: PluckEachArgs<ValidatedPluckEachColumnNames<ColumnNames, TableColumnNames<I['DB'], I['table']>>, BaseModelColumnTypes<ValidatedPluckEachColumnNames<ColumnNames, TableColumnNames<I['DB'], I['table']>>, I>>): Promise<void>;
|
|
1449
|
+
static pluckEach<T extends typeof Dream, I extends InstanceType<T>, const ColumnNames extends TableColumnNames<I['DB'], I['table']>[]>(this: T, ...args: PluckEachArgs<ColumnNames, BaseModelColumnTypes<ColumnNames, I>>): Promise<void>;
|
|
1449
1450
|
/**
|
|
1450
1451
|
* Used in conjunction with the Sortable decorator, `resort`
|
|
1451
1452
|
* takes a list of sortable fields, and for each one, finds and
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SelectArg, SelectExpression } from 'kysely';
|
|
2
2
|
import Dream from '../Dream.js';
|
|
3
3
|
import { PassthroughOnClause, WhereStatement } from '../types/associations/shared.js';
|
|
4
|
-
import { CreateOrFindByExtraOpts, DefaultScopeName, DreamColumnNames, DreamSerializerKey, FindablePropertiesForClass, OrderDir, PassthroughColumnNames, PluckEachArgs, PrimaryKeyForFind, TableColumnNames, UpdateableProperties, UpdateOrCreateByExtraOpts } from '../types/dream.js';
|
|
4
|
+
import { CreateOrFindByExtraOpts, DefaultScopeName, DreamColumnNames, DreamSerializerKey, FindablePropertiesForClass, OrderDir, PassthroughColumnNames, PluckEachArgs, PrimaryKeyForFind, TableColumnNames, UpdateableProperties, UpdateOrCreateByExtraOpts, ValidatedPluckEachColumnNames } from '../types/dream.js';
|
|
5
5
|
import { BaseModelColumnTypes, FindEachOpts, LoadForModifierFn, QueryWithJoinedAssociationsType, QueryWithJoinedAssociationsTypeAndNoPreload } from '../types/query.js';
|
|
6
6
|
import { JoinedAssociation, JoinedAssociationsTypeFromAssociations, VariadicJoinsArgs, VariadicLeftJoinLoadArgs, VariadicLoadArgs } from '../types/variadic.js';
|
|
7
7
|
import DreamTransaction from './DreamTransaction.js';
|
|
@@ -730,7 +730,8 @@ export default class DreamClassTransactionBuilder<DreamClass extends typeof Drea
|
|
|
730
730
|
* @param fields - A list of fields to pluck, followed by a callback function to call for each set of found fields
|
|
731
731
|
* @returns void
|
|
732
732
|
*/
|
|
733
|
-
pluckEach<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>,
|
|
733
|
+
pluckEach<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>, const ColumnNames extends unknown[]>(this: I, ...args: PluckEachArgs<ValidatedPluckEachColumnNames<ColumnNames, keyof UpdateableProperties<DreamInstance>>, BaseModelColumnTypes<ValidatedPluckEachColumnNames<ColumnNames, keyof UpdateableProperties<DreamInstance>>, DreamInstance>>): Promise<void>;
|
|
734
|
+
pluckEach<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>, const ColumnNames extends (keyof UpdateableProperties<DreamInstance>)[]>(this: I, ...args: PluckEachArgs<ColumnNames, BaseModelColumnTypes<ColumnNames, DreamInstance>>): Promise<void>;
|
|
734
735
|
/**
|
|
735
736
|
* Sends data through for use as passthrough data
|
|
736
737
|
* for the associations that require it.
|
|
@@ -2,7 +2,7 @@ import { DeleteQueryBuilder, SelectQueryBuilder, UpdateQueryBuilder } from 'kyse
|
|
|
2
2
|
import Dream from '../Dream.js';
|
|
3
3
|
import { ColumnNamesAccountingForJoinedAssociations, InternalWhereStatement, LimitStatement, OffsetStatement, OrderQueryStatement, PassthroughOnClause, WhereStatement, WhereStatementForJoinedAssociation } from '../types/associations/shared.js';
|
|
4
4
|
import { DbConnectionType } from '../types/db.js';
|
|
5
|
-
import { AllDefaultScopeNames, DefaultScopeName, DreamColumnNames, DreamConstructorType, DreamSerializerKey, DreamTableSchema, OrderDir, PassthroughColumnNames, PluckEachArgs, PrimaryKeyForFind, RelaxedJoinAndStatement, RelaxedJoinStatement, RelaxedPreloadOnStatement, RelaxedPreloadStatement, TableColumnNames, TableOrAssociationName, UpdateableProperties } from '../types/dream.js';
|
|
5
|
+
import { AllDefaultScopeNames, DefaultScopeName, DreamColumnNames, DreamConstructorType, DreamSerializerKey, DreamTableSchema, OrderDir, PassthroughColumnNames, PluckEachArgs, PrimaryKeyForFind, RelaxedJoinAndStatement, RelaxedJoinStatement, RelaxedPreloadOnStatement, RelaxedPreloadStatement, TableColumnNames, TableOrAssociationName, UpdateableProperties, ValidatedPluckEachColumnNames } from '../types/dream.js';
|
|
6
6
|
import { CursorPaginatedDreamQueryOptions, CursorPaginatedDreamQueryResult, DefaultQueryTypeOptions, ExtendQueryType, LoadForModifierFn, NamespacedOrBaseModelColumnTypes, PaginatedDreamQueryOptions, PaginatedDreamQueryResult, QueryToKyselyDBType, QueryToKyselyTableNamesType } from '../types/query.js';
|
|
7
7
|
import { JoinedAssociation, JoinedAssociationsTypeFromAssociations, QueryTypeOptions, VariadicJoinsArgs, VariadicLeftJoinLoadArgs, VariadicLoadArgs } from '../types/variadic.js';
|
|
8
8
|
import DreamTransaction from './DreamTransaction.js';
|
|
@@ -1006,7 +1006,8 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
|
|
|
1006
1006
|
* @returns void
|
|
1007
1007
|
* @throws BatchingIncompatibleWithLimitOrOffset if the query carries a `limit` or `offset`
|
|
1008
1008
|
*/
|
|
1009
|
-
pluckEach<Q extends Query<DreamInstance, QueryTypeOpts>,
|
|
1009
|
+
pluckEach<Q extends Query<DreamInstance, QueryTypeOpts>, const ColumnNames extends unknown[]>(this: Q, ...args: PluckEachArgs<ValidatedPluckEachColumnNames<ColumnNames, ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DreamInstance['DB'], QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>>, NamespacedOrBaseModelColumnTypes<ValidatedPluckEachColumnNames<ColumnNames, ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DreamInstance['DB'], QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>>, Q, DreamInstance>>): Promise<void>;
|
|
1010
|
+
pluckEach<Q extends Query<DreamInstance, QueryTypeOpts>, const ColumnNames extends ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DreamInstance['DB'], QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>[]>(this: Q, ...args: PluckEachArgs<ColumnNames, NamespacedOrBaseModelColumnTypes<ColumnNames, Q, DreamInstance>>): Promise<void>;
|
|
1010
1011
|
/**
|
|
1011
1012
|
* Retrieves an array containing all records matching the Query.
|
|
1012
1013
|
* Be careful using this, since it will attempt to pull every
|
|
@@ -29,7 +29,7 @@ type NonKyselySupportedSupplementalWhereClauseValues<DB, Schema, TableName, Colu
|
|
|
29
29
|
export type WhereStatementForDreamClass<DreamClass extends typeof Dream> = WhereStatement<InstanceType<DreamClass>>;
|
|
30
30
|
export type WhereStatementForDream<DreamInstance extends Dream> = WhereStatement<DreamInstance>;
|
|
31
31
|
type AssociationNameToDotReferencedColumns<DB, TableName extends keyof DB, AssociationName> = `${AssociationName & string}.${TableColumnNames<DB, TableName>}`;
|
|
32
|
-
export type ColumnNamesAccountingForJoinedAssociations<JoinedAssociations extends Readonly<JoinedAssociation[]>, DB, RootTableName extends keyof DB, RootTableAlias extends string> = JoinedAssociations['length'] extends 0 ? TableColumnNames<DB, RootTableName> : JoinedAssociationColumnNames<JoinedAssociations, DB, AssociationNameToDotReferencedColumns<DB, RootTableName & keyof DB, RootTableAlias>>;
|
|
32
|
+
export type ColumnNamesAccountingForJoinedAssociations<JoinedAssociations extends Readonly<JoinedAssociation[]>, DB, RootTableName extends keyof DB, RootTableAlias extends string> = JoinedAssociations['length'] extends 0 ? TableColumnNames<DB, RootTableName> : TableColumnNames<DB, RootTableName> | JoinedAssociationColumnNames<JoinedAssociations, DB, AssociationNameToDotReferencedColumns<DB, RootTableName & keyof DB, RootTableAlias>>;
|
|
33
33
|
type JoinedAssociationColumnNames<JoinedAssociations extends Readonly<JoinedAssociation[]>, DB, AllColumnNames, Depth extends number = 0, CurrentJoinedAssociation = Readonly<JoinedAssociations[0]>, NextTableName = CurrentJoinedAssociation extends Readonly<JoinedAssociation> ? CurrentJoinedAssociation['table'] : never, NextAssociationName = CurrentJoinedAssociation extends Readonly<JoinedAssociation> ? CurrentJoinedAssociation['alias'] : never> = JoinedAssociations['length'] extends 0 ? AllColumnNames : Depth extends MAX_JOINED_TABLES_DEPTH ? AllColumnNames : JoinedAssociationColumnNames<ReadonlyTail<JoinedAssociations>, DB, AllColumnNames | AssociationNameToDotReferencedColumns<DB, NextTableName & keyof DB, NextAssociationName>, Inc<Depth>>;
|
|
34
34
|
type Whereable<R> = {
|
|
35
35
|
[K in keyof Selectable<R>]?: Selectable<R>[K] | Selectable<R>[K][];
|
|
@@ -265,4 +265,7 @@ export type AllDefaultScopeNames<DreamConf, ConnectionTypeConfig = DreamConf['co
|
|
|
265
265
|
export type NamedScopeName<DreamInstance extends Dream, Schema = DreamInstance['schema'], SchemaTable = Schema[DreamInstance['table'] & keyof Schema], SchemaNamedScopes extends string[] = SchemaTable['scopes' & keyof SchemaTable]['named' & keyof SchemaTable['scopes' & keyof SchemaTable]] & string[]> = SchemaNamedScopes[number];
|
|
266
266
|
export type DefaultOrNamedScopeName<DreamInstance extends Dream> = DefaultScopeName<DreamInstance> | NamedScopeName<DreamInstance>;
|
|
267
267
|
export type PluckEachArgs<ColumnNames extends unknown[], CbArgTypes extends unknown[]> = [...fields: ColumnNames] | [...fields: ColumnNames, callback: (...values: CbArgTypes) => void | Promise<void>] | [...fields: ColumnNames, callback: (...values: CbArgTypes) => void | Promise<void>, opts: FindEachOpts];
|
|
268
|
+
export type ValidatedPluckEachColumnNames<ColumnNames extends unknown[], AllowedColumnName> = {
|
|
269
|
+
[Index in keyof ColumnNames]: ColumnNames[Index] extends AllowedColumnName ? ColumnNames[Index] : AllowedColumnName;
|
|
270
|
+
};
|
|
268
271
|
export {};
|
|
@@ -46,7 +46,7 @@ export type ExtendQueryType<OriginalOpts extends Readonly<QueryTypeOptions>, Opt
|
|
|
46
46
|
allowOffset: Opts['allowOffset'] extends false ? false : OriginalOpts['allowOffset'];
|
|
47
47
|
allowPaginate: Opts['allowPaginate'] extends false ? false : OriginalOpts['allowPaginate'];
|
|
48
48
|
}>;
|
|
49
|
-
export type NamespacedColumnType<ColumnName, Q extends Query<any, any>, DreamInstance extends Dream, JoinedAssociationsArr = Q['queryTypeOpts']['joinedAssociations'], AssociationName = ColumnName extends `${infer Name extends string}.${string}` ? Name : never, RealColumnName = ColumnName extends `${string}.${infer Col extends string}` ? Col :
|
|
49
|
+
export type NamespacedColumnType<ColumnName, Q extends Query<any, any>, DreamInstance extends Dream, JoinedAssociationsArr = Q['queryTypeOpts']['joinedAssociations'], AssociationName = ColumnName extends `${infer Name extends string}.${string}` ? Name : never, RealColumnName = ColumnName extends `${string}.${infer Col extends string}` ? Col : ColumnName, JoinedAssociation extends FindInterfaceWithValue<JoinedAssociationsArr, 'alias', AssociationName> = FindInterfaceWithValue<JoinedAssociationsArr, 'alias', AssociationName>, JoinedTable = JoinedAssociation['table'] extends never ? DreamInstance['table'] : JoinedAssociation['table'], ReturnType = ModelColumnType<DreamInstance['schema'], JoinedTable, RealColumnName>> = ReturnType;
|
|
50
50
|
type NamespacedColumnTypes<ColumnNames, Q extends Query<any, any>, DreamInstance extends Dream> = ColumnNames extends Readonly<[infer First, ...infer Rest]> ? [
|
|
51
51
|
NamespacedColumnType<First, Q, DreamInstance>,
|
|
52
52
|
...NamespacedColumnTypes<Readonly<Rest>, Q, DreamInstance>
|
|
@@ -216,12 +216,14 @@ export type ColumnNamesAccountingForJoinedAssociations<
|
|
|
216
216
|
RootTableAlias extends string,
|
|
217
217
|
> = JoinedAssociations['length'] extends 0
|
|
218
218
|
? TableColumnNames<DB, RootTableName> // no associations; simply return the un-namespaced columns for the root table
|
|
219
|
-
:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
:
|
|
220
|
+
| TableColumnNames<DB, RootTableName>
|
|
221
|
+
| JoinedAssociationColumnNames<
|
|
222
|
+
JoinedAssociations,
|
|
223
|
+
DB,
|
|
224
|
+
// namespace columns for the root table
|
|
225
|
+
AssociationNameToDotReferencedColumns<DB, RootTableName & keyof DB, RootTableAlias>
|
|
226
|
+
>
|
|
225
227
|
type JoinedAssociationColumnNames<
|
|
226
228
|
JoinedAssociations extends Readonly<JoinedAssociation[]>,
|
|
227
229
|
DB,
|
|
@@ -925,3 +925,9 @@ export type PluckEachArgs<ColumnNames extends unknown[], CbArgTypes extends unkn
|
|
|
925
925
|
| [...fields: ColumnNames]
|
|
926
926
|
| [...fields: ColumnNames, callback: (...values: CbArgTypes) => void | Promise<void>]
|
|
927
927
|
| [...fields: ColumnNames, callback: (...values: CbArgTypes) => void | Promise<void>, opts: FindEachOpts]
|
|
928
|
+
|
|
929
|
+
export type ValidatedPluckEachColumnNames<ColumnNames extends unknown[], AllowedColumnName> = {
|
|
930
|
+
[Index in keyof ColumnNames]: ColumnNames[Index] extends AllowedColumnName
|
|
931
|
+
? ColumnNames[Index]
|
|
932
|
+
: AllowedColumnName
|
|
933
|
+
}
|
|
@@ -101,7 +101,7 @@ export type NamespacedColumnType<
|
|
|
101
101
|
// begin: inferred types
|
|
102
102
|
JoinedAssociationsArr = Q['queryTypeOpts']['joinedAssociations'],
|
|
103
103
|
AssociationName = ColumnName extends `${infer Name extends string}.${string}` ? Name : never,
|
|
104
|
-
RealColumnName = ColumnName extends `${string}.${infer Col extends string}` ? Col :
|
|
104
|
+
RealColumnName = ColumnName extends `${string}.${infer Col extends string}` ? Col : ColumnName,
|
|
105
105
|
JoinedAssociation extends FindInterfaceWithValue<
|
|
106
106
|
JoinedAssociationsArr,
|
|
107
107
|
'alias',
|