@rvoh/dream 2.28.3 → 2.29.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 +4 -2
- package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +3 -1
- package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +1 -1
- package/dist/cjs/src/dream/LoadBuilder.js +4 -2
- package/dist/cjs/src/dream/Query.js +2 -0
- package/dist/cjs/src/dream/internal/applyScopeBypassingSettingsToQuery.js +1 -1
- package/dist/cjs/src/dream/internal/loadDependentDestroyTree.js +1 -1
- package/dist/cjs/src/dream/internal/reload.js +3 -1
- package/dist/esm/src/Dream.js +4 -2
- package/dist/esm/src/dream/DreamClassTransactionBuilder.js +3 -1
- package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +1 -1
- package/dist/esm/src/dream/LoadBuilder.js +4 -2
- package/dist/esm/src/dream/Query.js +2 -0
- package/dist/esm/src/dream/internal/applyScopeBypassingSettingsToQuery.js +1 -1
- package/dist/esm/src/dream/internal/loadDependentDestroyTree.js +1 -1
- package/dist/esm/src/dream/internal/reload.js +3 -1
- package/dist/types/src/Dream.d.ts +3 -1
- package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +4 -2
- package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +1 -1
- package/dist/types/src/dream/LoadBuilder.d.ts +3 -1
- package/dist/types/src/dream/Query.d.ts +2 -0
- package/docs/classes/db.DreamMigrationHelpers.html +11 -11
- package/docs/classes/db.KyselyQueryDriver.html +43 -43
- package/docs/classes/db.PostgresQueryDriver.html +44 -44
- package/docs/classes/db.QueryDriverBase.html +42 -42
- 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.SortableBatchRequiresTooManyScopeLocks.html +3 -3
- package/docs/classes/errors.SortableScopeDidNotStabilize.html +3 -3
- package/docs/classes/errors.SortableScopeLockWaitTimedOut.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 +129 -128
- 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 +69 -68
- 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
|
@@ -878,6 +878,8 @@ export default class Dream {
|
|
|
878
878
|
});
|
|
879
879
|
}
|
|
880
880
|
/**
|
|
881
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
882
|
+
*
|
|
881
883
|
* Returns a query which bypasses user-removable default scopes, including on
|
|
882
884
|
* association loads. An STI child's reserved type discriminator remains
|
|
883
885
|
* enforced; query the STI base model to span its registered children.
|
|
@@ -885,7 +887,7 @@ export default class Dream {
|
|
|
885
887
|
* @returns A query which bypasses user-removable default scopes
|
|
886
888
|
*/
|
|
887
889
|
static removeAllDefaultScopes() {
|
|
888
|
-
return this.query()
|
|
890
|
+
return this.query()['removeAllDefaultScopes']();
|
|
889
891
|
}
|
|
890
892
|
/**
|
|
891
893
|
* imports an object from the IOC. This is usually done in rare cases,
|
|
@@ -3183,7 +3185,7 @@ export default class Dream {
|
|
|
3183
3185
|
* this will raise an exception.
|
|
3184
3186
|
*
|
|
3185
3187
|
* ```ts
|
|
3186
|
-
* const user = await User.
|
|
3188
|
+
* const user = await User.removeDefaultScope('dream:SoftDelete').last()
|
|
3187
3189
|
* await user.undestroy()
|
|
3188
3190
|
* ```
|
|
3189
3191
|
*
|
|
@@ -629,6 +629,8 @@ export default class DreamClassTransactionBuilder {
|
|
|
629
629
|
return new Query(this.dreamInstance).txn(this.dreamTransaction);
|
|
630
630
|
}
|
|
631
631
|
/**
|
|
632
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
633
|
+
*
|
|
632
634
|
* Returns a query which bypasses user-removable default scopes, including on
|
|
633
635
|
* association loads. An STI child's reserved type discriminator remains
|
|
634
636
|
* enforced; query the STI base model to span its registered children.
|
|
@@ -636,7 +638,7 @@ export default class DreamClassTransactionBuilder {
|
|
|
636
638
|
* @returns A query which bypasses user-removable default scopes
|
|
637
639
|
*/
|
|
638
640
|
removeAllDefaultScopes() {
|
|
639
|
-
return this.queryInstance()
|
|
641
|
+
return this.queryInstance()['removeAllDefaultScopes']();
|
|
640
642
|
}
|
|
641
643
|
/**
|
|
642
644
|
* Prevents a specific default scope from applying when
|
|
@@ -227,7 +227,7 @@ export default class DreamInstanceTransactionBuilder {
|
|
|
227
227
|
* this will raise an exception.
|
|
228
228
|
*
|
|
229
229
|
* ```ts
|
|
230
|
-
* const user = await User.
|
|
230
|
+
* const user = await User.removeDefaultScope('dream:SoftDelete').last()
|
|
231
231
|
* await user.txn(txn).undestroy()
|
|
232
232
|
* ```
|
|
233
233
|
*
|
|
@@ -44,6 +44,8 @@ export default class LoadBuilder {
|
|
|
44
44
|
return this;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
48
|
+
*
|
|
47
49
|
* Prevents user-removable default scopes from applying when loading
|
|
48
50
|
* associations. An associated STI child's reserved type discriminator remains
|
|
49
51
|
* enforced; loading through its STI base still spans registered children.
|
|
@@ -52,14 +54,14 @@ export default class LoadBuilder {
|
|
|
52
54
|
* const user = await User.firstOrFail()
|
|
53
55
|
* const loaded = await user
|
|
54
56
|
* .load('posts')
|
|
55
|
-
* .
|
|
57
|
+
* .removeDefaultScope('dream:SoftDelete')
|
|
56
58
|
* .execute()
|
|
57
59
|
* ```
|
|
58
60
|
*
|
|
59
61
|
* @returns The LoadBuilder instance for chaining
|
|
60
62
|
*/
|
|
61
63
|
removeAllDefaultScopes() {
|
|
62
|
-
this.query = this.query
|
|
64
|
+
this.query = this.query['removeAllDefaultScopes']();
|
|
63
65
|
return this;
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
@@ -778,6 +778,8 @@ export default class Query {
|
|
|
778
778
|
});
|
|
779
779
|
}
|
|
780
780
|
/**
|
|
781
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
782
|
+
*
|
|
781
783
|
* Prevents user-removable default scopes from applying when the Query is
|
|
782
784
|
* executed, including when associations are loaded. An STI child's reserved
|
|
783
785
|
* type discriminator remains enforced; query the STI base model to span its
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function applyScopeBypassingSettingsToQuery(query, { bypassAllDefaultScopes, defaultScopesToBypass, }) {
|
|
2
2
|
if (bypassAllDefaultScopes)
|
|
3
|
-
query = query
|
|
3
|
+
query = query['removeAllDefaultScopes']();
|
|
4
4
|
defaultScopesToBypass.forEach(defaultScopeToBypass => {
|
|
5
5
|
query = query.removeDefaultScope(defaultScopeToBypass);
|
|
6
6
|
});
|
|
@@ -21,7 +21,7 @@ export default async function loadDependentDestroyTree(dream, txn, { reallyDestr
|
|
|
21
21
|
loadBuilder = loadBuilder.load(...args);
|
|
22
22
|
}
|
|
23
23
|
if (bypassAllDefaultScopes) {
|
|
24
|
-
loadBuilder = loadBuilder
|
|
24
|
+
loadBuilder = loadBuilder['removeAllDefaultScopes']();
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
for (const scopeName of defaultScopesToBypass) {
|
|
@@ -10,7 +10,9 @@ export default async function reload(dream, txn = null) {
|
|
|
10
10
|
// we have persisted are not yet propagated
|
|
11
11
|
else
|
|
12
12
|
query = query.connection('primary');
|
|
13
|
-
query = query
|
|
13
|
+
query = query['removeAllDefaultScopes']().where({
|
|
14
|
+
[dream['_primaryKey']]: dream.primaryKeyValue(),
|
|
15
|
+
});
|
|
14
16
|
const reloadedRecord = await query.firstOrFail();
|
|
15
17
|
dream.setAttributes(reloadedRecord.getAttributes());
|
|
16
18
|
dream['freezeAttributes']();
|
package/dist/esm/src/Dream.js
CHANGED
|
@@ -878,6 +878,8 @@ export default class Dream {
|
|
|
878
878
|
});
|
|
879
879
|
}
|
|
880
880
|
/**
|
|
881
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
882
|
+
*
|
|
881
883
|
* Returns a query which bypasses user-removable default scopes, including on
|
|
882
884
|
* association loads. An STI child's reserved type discriminator remains
|
|
883
885
|
* enforced; query the STI base model to span its registered children.
|
|
@@ -885,7 +887,7 @@ export default class Dream {
|
|
|
885
887
|
* @returns A query which bypasses user-removable default scopes
|
|
886
888
|
*/
|
|
887
889
|
static removeAllDefaultScopes() {
|
|
888
|
-
return this.query()
|
|
890
|
+
return this.query()['removeAllDefaultScopes']();
|
|
889
891
|
}
|
|
890
892
|
/**
|
|
891
893
|
* imports an object from the IOC. This is usually done in rare cases,
|
|
@@ -3183,7 +3185,7 @@ export default class Dream {
|
|
|
3183
3185
|
* this will raise an exception.
|
|
3184
3186
|
*
|
|
3185
3187
|
* ```ts
|
|
3186
|
-
* const user = await User.
|
|
3188
|
+
* const user = await User.removeDefaultScope('dream:SoftDelete').last()
|
|
3187
3189
|
* await user.undestroy()
|
|
3188
3190
|
* ```
|
|
3189
3191
|
*
|
|
@@ -629,6 +629,8 @@ export default class DreamClassTransactionBuilder {
|
|
|
629
629
|
return new Query(this.dreamInstance).txn(this.dreamTransaction);
|
|
630
630
|
}
|
|
631
631
|
/**
|
|
632
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
633
|
+
*
|
|
632
634
|
* Returns a query which bypasses user-removable default scopes, including on
|
|
633
635
|
* association loads. An STI child's reserved type discriminator remains
|
|
634
636
|
* enforced; query the STI base model to span its registered children.
|
|
@@ -636,7 +638,7 @@ export default class DreamClassTransactionBuilder {
|
|
|
636
638
|
* @returns A query which bypasses user-removable default scopes
|
|
637
639
|
*/
|
|
638
640
|
removeAllDefaultScopes() {
|
|
639
|
-
return this.queryInstance()
|
|
641
|
+
return this.queryInstance()['removeAllDefaultScopes']();
|
|
640
642
|
}
|
|
641
643
|
/**
|
|
642
644
|
* Prevents a specific default scope from applying when
|
|
@@ -227,7 +227,7 @@ export default class DreamInstanceTransactionBuilder {
|
|
|
227
227
|
* this will raise an exception.
|
|
228
228
|
*
|
|
229
229
|
* ```ts
|
|
230
|
-
* const user = await User.
|
|
230
|
+
* const user = await User.removeDefaultScope('dream:SoftDelete').last()
|
|
231
231
|
* await user.txn(txn).undestroy()
|
|
232
232
|
* ```
|
|
233
233
|
*
|
|
@@ -44,6 +44,8 @@ export default class LoadBuilder {
|
|
|
44
44
|
return this;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
48
|
+
*
|
|
47
49
|
* Prevents user-removable default scopes from applying when loading
|
|
48
50
|
* associations. An associated STI child's reserved type discriminator remains
|
|
49
51
|
* enforced; loading through its STI base still spans registered children.
|
|
@@ -52,14 +54,14 @@ export default class LoadBuilder {
|
|
|
52
54
|
* const user = await User.firstOrFail()
|
|
53
55
|
* const loaded = await user
|
|
54
56
|
* .load('posts')
|
|
55
|
-
* .
|
|
57
|
+
* .removeDefaultScope('dream:SoftDelete')
|
|
56
58
|
* .execute()
|
|
57
59
|
* ```
|
|
58
60
|
*
|
|
59
61
|
* @returns The LoadBuilder instance for chaining
|
|
60
62
|
*/
|
|
61
63
|
removeAllDefaultScopes() {
|
|
62
|
-
this.query = this.query
|
|
64
|
+
this.query = this.query['removeAllDefaultScopes']();
|
|
63
65
|
return this;
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
@@ -778,6 +778,8 @@ export default class Query {
|
|
|
778
778
|
});
|
|
779
779
|
}
|
|
780
780
|
/**
|
|
781
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
782
|
+
*
|
|
781
783
|
* Prevents user-removable default scopes from applying when the Query is
|
|
782
784
|
* executed, including when associations are loaded. An STI child's reserved
|
|
783
785
|
* type discriminator remains enforced; query the STI base model to span its
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function applyScopeBypassingSettingsToQuery(query, { bypassAllDefaultScopes, defaultScopesToBypass, }) {
|
|
2
2
|
if (bypassAllDefaultScopes)
|
|
3
|
-
query = query
|
|
3
|
+
query = query['removeAllDefaultScopes']();
|
|
4
4
|
defaultScopesToBypass.forEach(defaultScopeToBypass => {
|
|
5
5
|
query = query.removeDefaultScope(defaultScopeToBypass);
|
|
6
6
|
});
|
|
@@ -21,7 +21,7 @@ export default async function loadDependentDestroyTree(dream, txn, { reallyDestr
|
|
|
21
21
|
loadBuilder = loadBuilder.load(...args);
|
|
22
22
|
}
|
|
23
23
|
if (bypassAllDefaultScopes) {
|
|
24
|
-
loadBuilder = loadBuilder
|
|
24
|
+
loadBuilder = loadBuilder['removeAllDefaultScopes']();
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
for (const scopeName of defaultScopesToBypass) {
|
|
@@ -10,7 +10,9 @@ export default async function reload(dream, txn = null) {
|
|
|
10
10
|
// we have persisted are not yet propagated
|
|
11
11
|
else
|
|
12
12
|
query = query.connection('primary');
|
|
13
|
-
query = query
|
|
13
|
+
query = query['removeAllDefaultScopes']().where({
|
|
14
|
+
[dream['_primaryKey']]: dream.primaryKeyValue(),
|
|
15
|
+
});
|
|
14
16
|
const reloadedRecord = await query.firstOrFail();
|
|
15
17
|
dream.setAttributes(reloadedRecord.getAttributes());
|
|
16
18
|
dream['freezeAttributes']();
|
|
@@ -594,6 +594,8 @@ export default class Dream {
|
|
|
594
594
|
*/
|
|
595
595
|
static get associationNames(): string[];
|
|
596
596
|
/**
|
|
597
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
598
|
+
*
|
|
597
599
|
* Returns a query which bypasses user-removable default scopes, including on
|
|
598
600
|
* association loads. An STI child's reserved type discriminator remains
|
|
599
601
|
* enforced; query the STI base model to span its registered children.
|
|
@@ -2508,7 +2510,7 @@ export default class Dream {
|
|
|
2508
2510
|
* this will raise an exception.
|
|
2509
2511
|
*
|
|
2510
2512
|
* ```ts
|
|
2511
|
-
* const user = await User.
|
|
2513
|
+
* const user = await User.removeDefaultScope('dream:SoftDelete').last()
|
|
2512
2514
|
* await user.undestroy()
|
|
2513
2515
|
* ```
|
|
2514
2516
|
*
|
|
@@ -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 {
|
|
4
|
+
import { AllDefaultScopeNames, CreateOrFindByExtraOpts, 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';
|
|
@@ -599,6 +599,8 @@ export default class DreamClassTransactionBuilder<DreamClass extends typeof Drea
|
|
|
599
599
|
*/
|
|
600
600
|
queryInstance<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>>(this: I): Query<DreamInstance>;
|
|
601
601
|
/**
|
|
602
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
603
|
+
*
|
|
602
604
|
* Returns a query which bypasses user-removable default scopes, including on
|
|
603
605
|
* association loads. An STI child's reserved type discriminator remains
|
|
604
606
|
* enforced; query the STI base model to span its registered children.
|
|
@@ -612,7 +614,7 @@ export default class DreamClassTransactionBuilder<DreamClass extends typeof Drea
|
|
|
612
614
|
*
|
|
613
615
|
* @returns A new Query which will prevent a specific default scope from applying
|
|
614
616
|
*/
|
|
615
|
-
removeDefaultScope<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>>(this: I, scopeName:
|
|
617
|
+
removeDefaultScope<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>>(this: I, scopeName: AllDefaultScopeNames<DreamInstance>): Query<DreamInstance>;
|
|
616
618
|
/**
|
|
617
619
|
* Returns the last record corresponding to the
|
|
618
620
|
* model, ordered by primary key.
|
|
@@ -207,7 +207,7 @@ export default class DreamInstanceTransactionBuilder<DreamInstance extends Dream
|
|
|
207
207
|
* this will raise an exception.
|
|
208
208
|
*
|
|
209
209
|
* ```ts
|
|
210
|
-
* const user = await User.
|
|
210
|
+
* const user = await User.removeDefaultScope('dream:SoftDelete').last()
|
|
211
211
|
* await user.txn(txn).undestroy()
|
|
212
212
|
* ```
|
|
213
213
|
*
|
|
@@ -41,6 +41,8 @@ export default class LoadBuilder<DreamInstance extends Dream> {
|
|
|
41
41
|
*/
|
|
42
42
|
removeDefaultScope<I extends LoadBuilder<DreamInstance>>(this: I, scopeName: AllDefaultScopeNames<DreamInstance>): I;
|
|
43
43
|
/**
|
|
44
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
45
|
+
*
|
|
44
46
|
* Prevents user-removable default scopes from applying when loading
|
|
45
47
|
* associations. An associated STI child's reserved type discriminator remains
|
|
46
48
|
* enforced; loading through its STI base still spans registered children.
|
|
@@ -49,7 +51,7 @@ export default class LoadBuilder<DreamInstance extends Dream> {
|
|
|
49
51
|
* const user = await User.firstOrFail()
|
|
50
52
|
* const loaded = await user
|
|
51
53
|
* .load('posts')
|
|
52
|
-
* .
|
|
54
|
+
* .removeDefaultScope('dream:SoftDelete')
|
|
53
55
|
* .execute()
|
|
54
56
|
* ```
|
|
55
57
|
*
|
|
@@ -511,6 +511,8 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
|
|
|
511
511
|
*/
|
|
512
512
|
private setAssociationQueryBase;
|
|
513
513
|
/**
|
|
514
|
+
* @deprecated Use {@link removeDefaultScope} instead. This method will become private in v3.
|
|
515
|
+
*
|
|
514
516
|
* Prevents user-removable default scopes from applying when the Query is
|
|
515
517
|
* executed, including when associations are loaded. An STI child's reserved
|
|
516
518
|
* type discriminator remains enforced; query the STI base model to span its
|