@rvoh/dream 2.5.7 → 2.6.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 +37 -66
- package/dist/cjs/src/decorators/class/STI.js +2 -2
- package/dist/cjs/src/dream/LeftJoinLoadBuilder.js +16 -10
- package/dist/cjs/src/dream/LoadBuilder.js +70 -9
- package/dist/cjs/src/dream/Query.js +5 -6
- package/dist/cjs/src/dream/constants.js +2 -0
- package/dist/cjs/src/dream/internal/buildAssociationPaths.js +33 -0
- package/dist/cjs/src/dream/internal/buildDependentDestroyPreloadPaths.js +43 -0
- package/dist/cjs/src/dream/internal/buildSerializerPreloadPaths.js +38 -0
- package/dist/cjs/src/dream/internal/destroyAssociatedRecords.js +14 -6
- package/dist/cjs/src/dream/internal/destroyDream.js +7 -1
- package/dist/cjs/src/dream/internal/loadDependentDestroyTree.js +35 -0
- package/dist/cjs/src/dream/internal/resolveSerializerAssociationEdges.js +53 -0
- package/dist/cjs/src/serializer/SerializerRenderer.js +1 -1
- package/dist/cjs/src/serializer/builders/DreamSerializerBuilder.js +114 -52
- package/dist/cjs/src/serializer/builders/ObjectSerializerBuilder.js +111 -41
- package/dist/cjs/src/types/recursiveSerialization.js +1 -0
- package/dist/esm/src/Dream.js +37 -66
- package/dist/esm/src/decorators/class/STI.js +2 -2
- package/dist/esm/src/dream/LeftJoinLoadBuilder.js +16 -10
- package/dist/esm/src/dream/LoadBuilder.js +70 -9
- package/dist/esm/src/dream/Query.js +5 -6
- package/dist/esm/src/dream/constants.js +2 -0
- package/dist/esm/src/dream/internal/buildAssociationPaths.js +33 -0
- package/dist/esm/src/dream/internal/buildDependentDestroyPreloadPaths.js +43 -0
- package/dist/esm/src/dream/internal/buildSerializerPreloadPaths.js +38 -0
- package/dist/esm/src/dream/internal/destroyAssociatedRecords.js +14 -6
- package/dist/esm/src/dream/internal/destroyDream.js +7 -1
- package/dist/esm/src/dream/internal/loadDependentDestroyTree.js +35 -0
- package/dist/esm/src/dream/internal/resolveSerializerAssociationEdges.js +53 -0
- package/dist/esm/src/serializer/SerializerRenderer.js +1 -1
- package/dist/esm/src/serializer/builders/DreamSerializerBuilder.js +114 -52
- package/dist/esm/src/serializer/builders/ObjectSerializerBuilder.js +111 -41
- package/dist/esm/src/types/recursiveSerialization.js +1 -0
- package/dist/types/src/Dream.d.ts +25 -10
- package/dist/types/src/decorators/Decorators.d.ts +8 -0
- package/dist/types/src/decorators/class/STI.d.ts +1 -3
- package/dist/types/src/decorators/field/sortable/Sortable.d.ts +9 -0
- package/dist/types/src/decorators/field/validation/Validates.d.ts +4 -0
- package/dist/types/src/decorators/static-method/Scope.d.ts +4 -0
- package/dist/types/src/dream/LeftJoinLoadBuilder.d.ts +16 -10
- package/dist/types/src/dream/LoadBuilder.d.ts +63 -10
- package/dist/types/src/dream/Query.d.ts +1 -1
- package/dist/types/src/dream/constants.d.ts +2 -0
- package/dist/types/src/dream/internal/buildAssociationPaths.d.ts +12 -0
- package/dist/types/src/dream/internal/buildDependentDestroyPreloadPaths.d.ts +17 -0
- package/dist/types/src/dream/internal/buildSerializerPreloadPaths.d.ts +3 -0
- package/dist/types/src/dream/internal/convertDreamClassAndAssociationNameTupleArrayToPreloadArgs.d.ts +1 -1
- package/dist/types/src/dream/internal/destroyAssociatedRecords.d.ts +5 -1
- package/dist/types/src/dream/internal/loadDependentDestroyTree.d.ts +17 -0
- package/dist/types/src/dream/internal/resolveSerializerAssociationEdges.d.ts +13 -0
- package/dist/types/src/serializer/builders/DreamSerializerBuilder.d.ts +164 -63
- package/dist/types/src/serializer/builders/ObjectSerializerBuilder.d.ts +126 -43
- package/dist/types/src/types/associations/belongsTo.d.ts +34 -0
- package/dist/types/src/types/associations/belongsTo.ts +41 -0
- package/dist/types/src/types/associations/hasMany.d.ts +18 -0
- package/dist/types/src/types/associations/hasMany.ts +18 -0
- package/dist/types/src/types/associations/shared.d.ts +71 -0
- package/dist/types/src/types/associations/shared.ts +74 -0
- package/dist/types/src/types/dream.d.ts +16 -0
- package/dist/types/src/types/dream.ts +18 -0
- package/dist/types/src/types/lifecycle.d.ts +18 -0
- package/dist/types/src/types/lifecycle.ts +18 -0
- package/dist/types/src/types/query.d.ts +3 -0
- package/dist/types/src/types/query.ts +3 -0
- package/dist/types/src/types/recursiveSerialization.d.ts +8 -0
- package/dist/types/src/types/recursiveSerialization.ts +10 -0
- package/dist/types/src/types/serializer.d.ts +8 -1
- package/dist/types/src/types/serializer.ts +8 -1
- package/docs/classes/db.DreamMigrationHelpers.html +9 -9
- package/docs/classes/db.KyselyQueryDriver.html +32 -32
- package/docs/classes/db.PostgresQueryDriver.html +33 -33
- package/docs/classes/db.QueryDriverBase.html +31 -31
- 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.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 +21 -20
- package/docs/classes/index.Dream.html +133 -126
- package/docs/classes/index.DreamApp.html +5 -5
- package/docs/classes/index.DreamTransaction.html +2 -2
- package/docs/classes/index.Env.html +2 -2
- package/docs/classes/index.Query.html +57 -57
- package/docs/classes/system.CliFileWriter.html +4 -4
- package/docs/classes/system.DreamBin.html +2 -2
- package/docs/classes/system.DreamCLI.html +6 -6
- package/docs/classes/system.DreamImporter.html +2 -2
- package/docs/classes/system.DreamLogos.html +2 -2
- package/docs/classes/system.DreamSerializerBuilder.html +177 -59
- package/docs/classes/system.ObjectSerializerBuilder.html +110 -34
- package/docs/classes/system.PathHelpers.html +3 -3
- package/docs/classes/utils.Encrypt.html +2 -2
- 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.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/internal/extractNestedPaths.js +0 -34
- package/dist/esm/src/dream/internal/extractNestedPaths.js +0 -34
- package/dist/types/src/dream/internal/extractNestedPaths.d.ts +0 -21
|
@@ -399,9 +399,26 @@ interface HasOptionsBase<
|
|
|
399
399
|
AssociationGlobalName & keyof GlobalModelNameTableMap<BaseInstance>
|
|
400
400
|
>,
|
|
401
401
|
> {
|
|
402
|
+
/**
|
|
403
|
+
* If `'destroy'`, associated records will be cascade-deleted when the base model is destroyed.
|
|
404
|
+
*/
|
|
402
405
|
dependent?: DependentOptions
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* A custom column on the associated model to use as the foreign key for this association,
|
|
409
|
+
* overriding the default convention-based foreign key.
|
|
410
|
+
*/
|
|
403
411
|
on?: TableColumnNames<BaseInstance['DB'], AssociationTableName & keyof BaseInstance['DB']>
|
|
404
412
|
|
|
413
|
+
/**
|
|
414
|
+
* A where clause applied whenever this association is loaded, scoping the association
|
|
415
|
+
* to only records matching the given conditions.
|
|
416
|
+
*
|
|
417
|
+
* ```ts
|
|
418
|
+
* @deco.HasMany('Collar', { and: { lost: false } })
|
|
419
|
+
* public currentCollars: Collar[]
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
405
422
|
and?: OnStatementForAssociationDefinition<
|
|
406
423
|
BaseInstance['DB'],
|
|
407
424
|
BaseInstance['schema'],
|
|
@@ -410,6 +427,15 @@ interface HasOptionsBase<
|
|
|
410
427
|
keyof BaseInstance['DB']
|
|
411
428
|
>
|
|
412
429
|
|
|
430
|
+
/**
|
|
431
|
+
* A negated where clause applied whenever this association is loaded, excluding
|
|
432
|
+
* records matching the given conditions.
|
|
433
|
+
*
|
|
434
|
+
* ```ts
|
|
435
|
+
* @deco.HasOne('Collar', { andNot: { lost: true } })
|
|
436
|
+
* public notLostCollar: Collar
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
413
439
|
andNot?: InternalWhereStatement<
|
|
414
440
|
BaseInstance,
|
|
415
441
|
BaseInstance['DB'],
|
|
@@ -419,6 +445,15 @@ interface HasOptionsBase<
|
|
|
419
445
|
keyof BaseInstance['DB']
|
|
420
446
|
>
|
|
421
447
|
|
|
448
|
+
/**
|
|
449
|
+
* An array of where clauses combined with OR logic, applied whenever this association
|
|
450
|
+
* is loaded. At least one of the clauses must match.
|
|
451
|
+
*
|
|
452
|
+
* ```ts
|
|
453
|
+
* @deco.HasMany('Balloon', { andAny: [{ color: 'red' }, { color: 'blue' }] })
|
|
454
|
+
* public redOrBlueBalloons: Balloon[]
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
422
457
|
andAny?: InternalWhereStatement<
|
|
423
458
|
BaseInstance,
|
|
424
459
|
BaseInstance['DB'],
|
|
@@ -428,9 +463,27 @@ interface HasOptionsBase<
|
|
|
428
463
|
keyof BaseInstance['DB']
|
|
429
464
|
>[]
|
|
430
465
|
|
|
466
|
+
/**
|
|
467
|
+
* Marks this as a polymorphic association, where the foreign key and a type column
|
|
468
|
+
* together identify the associated record across multiple tables.
|
|
469
|
+
*/
|
|
431
470
|
polymorphic?: boolean
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* A custom column on this model to use as the primary key for this association,
|
|
474
|
+
* instead of the default primary key (e.g., `'uuid'` instead of `'id'`).
|
|
475
|
+
*/
|
|
432
476
|
primaryKeyOverride?: DreamColumnNames<BaseInstance> | null
|
|
433
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Adds a join condition between a column on the associated model and a column on this model,
|
|
480
|
+
* so the association is scoped by matching column values across both models.
|
|
481
|
+
*
|
|
482
|
+
* ```ts
|
|
483
|
+
* @deco.HasMany('Post', { selfAnd: { species: 'targetSpecies' } })
|
|
484
|
+
* public postsMatchingSpecies: Post[]
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
434
487
|
selfAnd?: SelfOnStatement<
|
|
435
488
|
BaseInstance,
|
|
436
489
|
BaseInstance['DB'],
|
|
@@ -440,6 +493,10 @@ interface HasOptionsBase<
|
|
|
440
493
|
keyof BaseInstance['DB']
|
|
441
494
|
>
|
|
442
495
|
|
|
496
|
+
/**
|
|
497
|
+
* Adds a negated join condition between a column on the associated model and a column
|
|
498
|
+
* on this model, excluding records where the columns match.
|
|
499
|
+
*/
|
|
443
500
|
selfAndNot?: SelfOnStatement<
|
|
444
501
|
BaseInstance,
|
|
445
502
|
BaseInstance['DB'],
|
|
@@ -449,9 +506,26 @@ interface HasOptionsBase<
|
|
|
449
506
|
keyof BaseInstance['DB']
|
|
450
507
|
>
|
|
451
508
|
|
|
509
|
+
/**
|
|
510
|
+
* Used in conjunction with `through` to specify which association on the intermediate model
|
|
511
|
+
* should be used to reach the target model.
|
|
512
|
+
*/
|
|
452
513
|
source?: keyof BaseInstance['schema'][ForeignTableName]['associations']
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Loads this association through an intermediate association, similar to a SQL join
|
|
517
|
+
* through a join table.
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* @deco.HasMany('Rating', { through: 'posts' })
|
|
521
|
+
* public ratings: Rating[]
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
453
524
|
through?: ThroughAssociationName
|
|
454
525
|
|
|
526
|
+
/**
|
|
527
|
+
* A list of default scopes to bypass when loading this association.
|
|
528
|
+
*/
|
|
455
529
|
withoutDefaultScopes?: DefaultScopeNameForTable<
|
|
456
530
|
BaseInstance['schema'],
|
|
457
531
|
AssociationTableName & keyof BaseInstance['DB']
|
|
@@ -129,11 +129,27 @@ export type UpdateableAssociationProperties<DreamInstance extends Dream, Associa
|
|
|
129
129
|
export type AttributeKeys<I extends Dream, TableName extends AssociationTableNames<I['DB'], I['schema']> & I['table'] = I['table'], VirtualColumns = DreamVirtualColumns<I>> = keyof (Updateable<I['DB'][TableName]> & (VirtualColumns extends readonly any[] ? Record<VirtualColumns[number], any> : object));
|
|
130
130
|
export type UpdateableProperties<I extends Dream, TableName extends AssociationTableNames<I['DB'], I['schema']> & I['table'] = I['table'], VirtualColumns = DreamVirtualColumns<I>> = Partial<Updateable<I['DB'][TableName]> & (VirtualColumns extends readonly any[] ? Record<VirtualColumns[number], any> : object) & (AssociatedModelParam<I> extends never ? object : AssociatedModelParam<I>)>;
|
|
131
131
|
export interface CreateOrFindByExtraOpts<T extends typeof Dream> {
|
|
132
|
+
/**
|
|
133
|
+
* Additional attributes to include when creating the record, but NOT used
|
|
134
|
+
* for finding the record if the create fails due to a uniqueness violation.
|
|
135
|
+
*/
|
|
132
136
|
createWith?: UpdateablePropertiesForClass<T>;
|
|
137
|
+
/**
|
|
138
|
+
* If `true`, skips all model lifecycle hooks (BeforeCreate, AfterCreate, etc.).
|
|
139
|
+
* Defaults to `false`.
|
|
140
|
+
*/
|
|
133
141
|
skipHooks?: boolean;
|
|
134
142
|
}
|
|
135
143
|
export interface UpdateOrCreateByExtraOpts<T extends typeof Dream> {
|
|
144
|
+
/**
|
|
145
|
+
* Additional attributes to include when creating or updating the record,
|
|
146
|
+
* but NOT used for finding the existing record.
|
|
147
|
+
*/
|
|
136
148
|
with?: UpdateablePropertiesForClass<T>;
|
|
149
|
+
/**
|
|
150
|
+
* If `true`, skips all model lifecycle hooks (BeforeCreate, AfterCreate,
|
|
151
|
+
* BeforeUpdate, AfterUpdate, etc.). Defaults to `false`.
|
|
152
|
+
*/
|
|
137
153
|
skipHooks?: boolean;
|
|
138
154
|
}
|
|
139
155
|
export type TableNameForGlobalModelName<I extends Dream, GMN extends keyof GlobalModelNameTableMap<I>> = GlobalModelNameTableMap<I>[GMN];
|
|
@@ -521,12 +521,30 @@ export type UpdateableProperties<
|
|
|
521
521
|
>
|
|
522
522
|
|
|
523
523
|
export interface CreateOrFindByExtraOpts<T extends typeof Dream> {
|
|
524
|
+
/**
|
|
525
|
+
* Additional attributes to include when creating the record, but NOT used
|
|
526
|
+
* for finding the record if the create fails due to a uniqueness violation.
|
|
527
|
+
*/
|
|
524
528
|
createWith?: UpdateablePropertiesForClass<T>
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* If `true`, skips all model lifecycle hooks (BeforeCreate, AfterCreate, etc.).
|
|
532
|
+
* Defaults to `false`.
|
|
533
|
+
*/
|
|
525
534
|
skipHooks?: boolean
|
|
526
535
|
}
|
|
527
536
|
|
|
528
537
|
export interface UpdateOrCreateByExtraOpts<T extends typeof Dream> {
|
|
538
|
+
/**
|
|
539
|
+
* Additional attributes to include when creating or updating the record,
|
|
540
|
+
* but NOT used for finding the existing record.
|
|
541
|
+
*/
|
|
529
542
|
with?: UpdateablePropertiesForClass<T>
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* If `true`, skips all model lifecycle hooks (BeforeCreate, AfterCreate,
|
|
546
|
+
* BeforeUpdate, AfterUpdate, etc.). Defaults to `false`.
|
|
547
|
+
*/
|
|
530
548
|
skipHooks?: boolean
|
|
531
549
|
}
|
|
532
550
|
|
|
@@ -10,9 +10,27 @@ export interface HookStatement {
|
|
|
10
10
|
ifChanged?: string[] | undefined;
|
|
11
11
|
}
|
|
12
12
|
export interface BeforeHookOpts<T extends Dream | null = null> {
|
|
13
|
+
/**
|
|
14
|
+
* Only run this hook if one of the specified columns is being changed in the
|
|
15
|
+
* current save operation.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* @deco.BeforeCreate({ ifChanging: ['email'] })
|
|
19
|
+
* public normalizeEmail() { ... }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
13
22
|
ifChanging?: T extends Dream ? DreamColumnNames<T>[] : string[];
|
|
14
23
|
}
|
|
15
24
|
export interface AfterHookOpts<T extends Dream | null = null> {
|
|
25
|
+
/**
|
|
26
|
+
* Only run this hook if one of the specified columns was changed in the
|
|
27
|
+
* most recent save operation.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* @deco.AfterUpdate({ ifChanged: ['email'] })
|
|
31
|
+
* public sendEmailVerification() { ... }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
16
34
|
ifChanged?: T extends Dream ? DreamColumnNames<T>[] : string[];
|
|
17
35
|
}
|
|
18
36
|
export interface HookStatementMap {
|
|
@@ -27,10 +27,28 @@ export interface HookStatement {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface BeforeHookOpts<T extends Dream | null = null> {
|
|
30
|
+
/**
|
|
31
|
+
* Only run this hook if one of the specified columns is being changed in the
|
|
32
|
+
* current save operation.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* @deco.BeforeCreate({ ifChanging: ['email'] })
|
|
36
|
+
* public normalizeEmail() { ... }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
30
39
|
ifChanging?: T extends Dream ? DreamColumnNames<T>[] : string[]
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
export interface AfterHookOpts<T extends Dream | null = null> {
|
|
43
|
+
/**
|
|
44
|
+
* Only run this hook if one of the specified columns was changed in the
|
|
45
|
+
* most recent save operation.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* @deco.AfterUpdate({ ifChanged: ['email'] })
|
|
49
|
+
* public sendEmailVerification() { ... }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
34
52
|
ifChanged?: T extends Dream ? DreamColumnNames<T>[] : string[]
|
|
35
53
|
}
|
|
36
54
|
|
|
@@ -30,6 +30,9 @@ export interface PreloadedDreamsAndWhatTheyPointTo {
|
|
|
30
30
|
pointsToPrimaryKey: string | bigint | number;
|
|
31
31
|
}
|
|
32
32
|
export interface FindEachOpts {
|
|
33
|
+
/**
|
|
34
|
+
* The number of records to load per batch. Defaults to 1000.
|
|
35
|
+
*/
|
|
33
36
|
batchSize?: number;
|
|
34
37
|
}
|
|
35
38
|
export type JoinTypes = 'inner' | 'left';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Dream from '../Dream.js';
|
|
2
|
+
export type DreamClassAndAssociationNameTuple = [typeof Dream, string];
|
|
3
|
+
export type RecursiveSerializerInfo = {
|
|
4
|
+
[associationName: string]: {
|
|
5
|
+
parentDreamClass: typeof Dream;
|
|
6
|
+
nestedSerializerInfo: RecursiveSerializerInfo;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Dream from '../Dream.js'
|
|
2
|
+
|
|
3
|
+
export type DreamClassAndAssociationNameTuple = [typeof Dream, string]
|
|
4
|
+
|
|
5
|
+
export type RecursiveSerializerInfo = {
|
|
6
|
+
[associationName: string]: {
|
|
7
|
+
parentDreamClass: typeof Dream
|
|
8
|
+
nestedSerializerInfo: RecursiveSerializerInfo
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -15,7 +15,14 @@ export interface InternalAnyTypedSerializerDelegatedAttribute {
|
|
|
15
15
|
type: 'delegatedAttribute';
|
|
16
16
|
targetName: string;
|
|
17
17
|
name: string;
|
|
18
|
-
options:
|
|
18
|
+
options: {
|
|
19
|
+
as?: string;
|
|
20
|
+
default?: any;
|
|
21
|
+
openapi?: OpenapiSchemaBodyShorthand | OpenapiShorthandPrimitiveTypes;
|
|
22
|
+
required?: false;
|
|
23
|
+
precision?: RoundingPrecision;
|
|
24
|
+
optional?: boolean;
|
|
25
|
+
};
|
|
19
26
|
}
|
|
20
27
|
export interface InternalAnyTypedSerializerCustomAttribute {
|
|
21
28
|
type: 'customAttribute';
|
|
@@ -18,7 +18,14 @@ export interface InternalAnyTypedSerializerDelegatedAttribute {
|
|
|
18
18
|
type: 'delegatedAttribute'
|
|
19
19
|
targetName: string
|
|
20
20
|
name: string
|
|
21
|
-
options:
|
|
21
|
+
options: {
|
|
22
|
+
as?: string
|
|
23
|
+
default?: any
|
|
24
|
+
openapi?: OpenapiSchemaBodyShorthand | OpenapiShorthandPrimitiveTypes
|
|
25
|
+
required?: false
|
|
26
|
+
precision?: RoundingPrecision
|
|
27
|
+
optional?: boolean
|
|
28
|
+
}
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
export interface InternalAnyTypedSerializerCustomAttribute {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>DreamMigrationHelpers | @rvoh/dream</title><meta name="description" content="Documentation for @rvoh/dream"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@rvoh/dream</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/db.html">db</a></li><li><a href="" aria-current="page">DreamMigrationHelpers</a></li></ul><h1>Class DreamMigrationHelpers</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>DreamMigrationHelpers | @rvoh/dream</title><meta name="description" content="Documentation for @rvoh/dream"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@rvoh/dream</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/db.html">db</a></li><li><a href="" aria-current="page">DreamMigrationHelpers</a></li></ul><h1>Class DreamMigrationHelpers</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L3">src/db/migration-helpers/DreamMigrationHelpers.ts:3</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
|
|
2
2
|
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="#adddeferrableuniqueconstraint" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>add<wbr/>Deferrable<wbr/>Unique<wbr/>Constraint</span></a>
|
|
3
3
|
<a href="#addenumvalue" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>add<wbr/>Enum<wbr/>Value</span></a>
|
|
4
4
|
<a href="#createextension" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>create<wbr/>Extension</span></a>
|
|
@@ -16,13 +16,13 @@ indexes.</p>
|
|
|
16
16
|
</div></li><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">columns</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">table</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span> <span class="tsd-signature-symbol">}</span></span><div class="tsd-comment tsd-typography"><p>Configuration options</p>
|
|
17
17
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span class="tsd-kind-property">columns</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><p>The names of the columns to include in the constraint</p>
|
|
18
18
|
</div></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">table</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><p>The name of the table</p>
|
|
19
|
-
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
19
|
+
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L41">src/db/migration-helpers/DreamMigrationHelpers.ts:41</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="addenumvalue"><code class="tsd-tag">Static</code><span>add<wbr/>Enum<wbr/>Value</span><a href="#addenumvalue" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="addenumvalue-1"><span class="tsd-kind-call-signature">addEnumValue</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">db</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">__namedParameters</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">AddValueToEnumOpts</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><a href="#addenumvalue-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Add a value to an enum.</p>
|
|
20
20
|
<p>Note that this always includes "IF NOT EXISTS", so is safe to re-run multiple times.</p>
|
|
21
21
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">db</span>: <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The Kysely database object passed into the migration up/down function</p>
|
|
22
22
|
</div></li><li><span><span class="tsd-kind-parameter">__namedParameters</span>: <span class="tsd-signature-type">AddValueToEnumOpts</span></span><div class="tsd-comment tsd-typography"><p>The options for adding the enum value</p>
|
|
23
23
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span>enumName</span></h5><div class="tsd-comment tsd-typography"><p>The name of the enum to modify</p>
|
|
24
24
|
</div></li><li class="tsd-parameter"><h5><span>value</span></h5><div class="tsd-comment tsd-typography"><p>The name of the value to add to the enum</p>
|
|
25
|
-
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
25
|
+
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L71">src/db/migration-helpers/DreamMigrationHelpers.ts:71</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="createextension"><code class="tsd-tag">Static</code><span>create<wbr/>Extension</span><a href="#createextension" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="createextension-1"><span class="tsd-kind-call-signature">createExtension</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">db</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">extensionName</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">ifNotExists</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">publicSchema</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><a href="#createextension-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Create a database extension.</p>
|
|
26
26
|
<pre><code><span class="hl-1"> </span><span class="hl-7">// Add the case insensitive extension</span><br/><span class="hl-1"> </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">DreamMigrationHelpers</span><span class="hl-1">.</span><span class="hl-5">createExtension</span><span class="hl-1">(</span><span class="hl-4">db</span><span class="hl-1">, </span><span class="hl-6">'citext'</span><span class="hl-1">)</span><br/><br/><span class="hl-1"> </span><span class="hl-7">// Add the pg trigram extension</span><br/><span class="hl-1"> </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">DreamMigrationHelpers</span><span class="hl-1">.</span><span class="hl-5">createExtension</span><span class="hl-1">(</span><span class="hl-4">db</span><span class="hl-1">, </span><span class="hl-6">'pg_trgm'</span><span class="hl-1">)</span>
|
|
27
27
|
</code><button>Copy</button></pre>
|
|
28
28
|
|
|
@@ -31,26 +31,26 @@ indexes.</p>
|
|
|
31
31
|
</div></li><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">ifNotExists</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">publicSchema</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = {}</span></span><div class="tsd-comment tsd-typography"><p>Configuration options</p>
|
|
32
32
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">ifNotExists</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>Only add the extension if it doesn't already exist</p>
|
|
33
33
|
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">publicSchema</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>Create using the public schema</p>
|
|
34
|
-
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
34
|
+
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L93">src/db/migration-helpers/DreamMigrationHelpers.ts:93</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="createginindex"><code class="tsd-tag">Static</code><span>create<wbr/>Gin<wbr/>Index</span><a href="#createginindex" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="createginindex-1"><span class="tsd-kind-call-signature">createGinIndex</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">db</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">indexName</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">column</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">table</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><a href="#createginindex-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Create a gin index</p>
|
|
35
35
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">db</span>: <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The Kysely database object passed into the migration up/down function</p>
|
|
36
36
|
</div></li><li><span><span class="tsd-kind-parameter">indexName</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The name of the constraint to create</p>
|
|
37
37
|
</div></li><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">column</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">table</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span> <span class="tsd-signature-symbol">}</span></span><div class="tsd-comment tsd-typography"><p>Configuration options</p>
|
|
38
38
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span class="tsd-kind-property">column</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><p>The name of the column to index</p>
|
|
39
39
|
</div></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">table</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><p>The name of the table</p>
|
|
40
|
-
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
40
|
+
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L115">src/db/migration-helpers/DreamMigrationHelpers.ts:115</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dropconstraint"><code class="tsd-tag">Static</code><span>drop<wbr/>Constraint</span><a href="#dropconstraint" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="dropconstraint-1"><span class="tsd-kind-call-signature">dropConstraint</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">db</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">constraintName</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">table</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><a href="#dropconstraint-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Drop a constraint</p>
|
|
41
41
|
<p>Note that this always includes "IF NOT EXISTS", so is safe to re-run multiple times.</p>
|
|
42
42
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">db</span>: <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The Kysely database object passed into the migration up/down function</p>
|
|
43
43
|
</div></li><li><span><span class="tsd-kind-parameter">constraintName</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The name of the constraint to create</p>
|
|
44
44
|
</div></li><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">table</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span> <span class="tsd-signature-symbol">}</span></span><div class="tsd-comment tsd-typography"><p>Configuration options</p>
|
|
45
45
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span class="tsd-kind-property">table</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><p>The name of the table</p>
|
|
46
|
-
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
46
|
+
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L138">src/db/migration-helpers/DreamMigrationHelpers.ts:138</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dropenumvalue"><code class="tsd-tag">Static</code><span>drop<wbr/>Enum<wbr/>Value</span><a href="#dropenumvalue" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="dropenumvalue-1"><span class="tsd-kind-call-signature">dropEnumValue</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">db</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">__namedParameters</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">DropValueFromEnumOpts</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><a href="#dropenumvalue-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Drop a value from an enum and replace it with a different enum already
|
|
47
47
|
present in the enum type (or optionally remove it from array columns).</p>
|
|
48
48
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">db</span>: <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The Kysely database object passed into the migration up/down function</p>
|
|
49
49
|
</div></li><li><span><span class="tsd-kind-parameter">__namedParameters</span>: <span class="tsd-signature-type">DropValueFromEnumOpts</span></span><div class="tsd-comment tsd-typography"><p>The options for dropping the enum value</p>
|
|
50
50
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><span>enumName</span></h5><div class="tsd-comment tsd-typography"><p>The name of the enum to modify</p>
|
|
51
51
|
</div></li><li class="tsd-parameter"><h5><span>value</span></h5><div class="tsd-comment tsd-typography"><p>The name of the value to drop from the enum</p>
|
|
52
52
|
</div></li><li class="tsd-parameter"><h5><span>replacements</span></h5><div class="tsd-comment tsd-typography"><p>Details about which table and column to change and which value to replace the dropped value with (or remove it if the column is an array)</p>
|
|
53
|
-
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
53
|
+
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L191">src/db/migration-helpers/DreamMigrationHelpers.ts:191</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="newtransaction"><code class="tsd-tag">Static</code><span>new<wbr/>Transaction</span><a href="#newtransaction" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="newtransaction-1"><span class="tsd-kind-call-signature">newTransaction</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span><a href="#newtransaction-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Forces a new transaction boundary in migration execution.</p>
|
|
54
54
|
<p>When called in a migration file, this method ensures that any existing transaction
|
|
55
55
|
is committed before this migration runs, and a new transaction is started before the
|
|
56
56
|
migration in this file. This is essential for migrations that depend on previously
|
|
@@ -61,7 +61,7 @@ enum values to be committed to the database first.</p>
|
|
|
61
61
|
<pre><code class="ts"><span class="hl-7">// first migration file: Add enum value</span><br/><span class="hl-3">export</span><span class="hl-1"> </span><span class="hl-0">async</span><span class="hl-1"> </span><span class="hl-0">function</span><span class="hl-1"> </span><span class="hl-5">up</span><span class="hl-1">(</span><span class="hl-4">db</span><span class="hl-1">: </span><span class="hl-9">Kysely</span><span class="hl-1"><</span><span class="hl-9">any</span><span class="hl-1">>): </span><span class="hl-9">Promise</span><span class="hl-1"><</span><span class="hl-9">void</span><span class="hl-1">> {</span><br/><span class="hl-1"> </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">DreamMigrationHelpers</span><span class="hl-1">.</span><span class="hl-5">addEnumValue</span><span class="hl-1">(</span><span class="hl-4">db</span><span class="hl-1">, {</span><br/><span class="hl-1"> </span><span class="hl-4">enumName:</span><span class="hl-1"> </span><span class="hl-6">'user_status'</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-4">value:</span><span class="hl-1"> </span><span class="hl-6">'premium'</span><br/><span class="hl-1"> })</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-7">// second migration file: Add check constraint that depends on the enum value</span><br/><span class="hl-3">export</span><span class="hl-1"> </span><span class="hl-0">async</span><span class="hl-1"> </span><span class="hl-0">function</span><span class="hl-1"> </span><span class="hl-5">up</span><span class="hl-1">(</span><span class="hl-4">db</span><span class="hl-1">: </span><span class="hl-9">Kysely</span><span class="hl-1"><</span><span class="hl-9">any</span><span class="hl-1">>): </span><span class="hl-9">Promise</span><span class="hl-1"><</span><span class="hl-9">void</span><span class="hl-1">> {</span><br/><span class="hl-1"> </span><span class="hl-4">DreamMigrationHelpers</span><span class="hl-1">.</span><span class="hl-5">newTransaction</span><span class="hl-1">() </span><span class="hl-7">// Ensure enum value is committed first</span><br/><br/><span class="hl-1"> </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">db</span><span class="hl-1">.</span><span class="hl-4">schema</span><br/><span class="hl-1"> .</span><span class="hl-5">alterTable</span><span class="hl-1">(</span><span class="hl-6">'users'</span><span class="hl-1">)</span><br/><span class="hl-1"> .</span><span class="hl-5">addCheckConstraint</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-6">'check_premium_users'</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">sql</span><span class="hl-6">`status = 'premium' OR credits < 100`</span><br/><span class="hl-1"> )</span><br/><span class="hl-1"> .</span><span class="hl-5">execute</span><span class="hl-1">()</span><br/><span class="hl-1">}</span>
|
|
62
62
|
</code><button type="button">Copy</button></pre>
|
|
63
63
|
|
|
64
|
-
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
64
|
+
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L179">src/db/migration-helpers/DreamMigrationHelpers.ts:179</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="renametable"><code class="tsd-tag">Static</code><span>rename<wbr/>Table</span><a href="#renametable" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="renametable-1"><span class="tsd-kind-call-signature">renameTable</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">db</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span> <span class="tsd-kind-parameter">from</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-kind-parameter">to</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><a href="#renametable-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Rename a table and its associated primary key sequence.</p>
|
|
65
65
|
<p>This method renames both the table and its primary key sequence to keep them
|
|
66
66
|
in sync. When PostgreSQL creates a table with a serial or bigserial primary key,
|
|
67
67
|
it automatically creates a sequence named <code>{tablename}_id_seq</code>. If you only rename
|
|
@@ -71,4 +71,4 @@ key column named 'id'.</p>
|
|
|
71
71
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">db</span>: <span class="tsd-signature-type">Kysely</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The Kysely database object passed into the migration up/down function</p>
|
|
72
72
|
</div></li><li><span><span class="tsd-kind-parameter">from</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The current name of the table to rename</p>
|
|
73
73
|
</div></li><li><span><span class="tsd-kind-parameter">to</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The new name for the table</p>
|
|
74
|
-
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/
|
|
74
|
+
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/daniel-nelson/dream/blob/d055cc606d0f3e5946fd3301086dfab30ff0914f/src/db/migration-helpers/DreamMigrationHelpers.ts#L19">src/db/migration-helpers/DreamMigrationHelpers.ts:19</a></li></ul></aside></div></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#adddeferrableuniqueconstraint"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>add<wbr/>Deferrable<wbr/>Unique<wbr/>Constraint</span></a><a href="#addenumvalue"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>add<wbr/>Enum<wbr/>Value</span></a><a href="#createextension"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>create<wbr/>Extension</span></a><a href="#createginindex"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>create<wbr/>Gin<wbr/>Index</span></a><a href="#dropconstraint"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>drop<wbr/>Constraint</span></a><a href="#dropenumvalue"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>drop<wbr/>Enum<wbr/>Value</span></a><a href="#newtransaction"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>new<wbr/>Transaction</span></a><a href="#renametable"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>rename<wbr/>Table</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@rvoh/dream</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|