@rvoh/dream 0.36.4 → 0.38.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.
Files changed (201) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/src/Dream.js +42 -32
  3. package/dist/cjs/src/decorators/field/association/HasMany.js +12 -12
  4. package/dist/cjs/src/decorators/field/association/HasOne.js +12 -12
  5. package/dist/cjs/src/decorators/field/association/shared.js +7 -7
  6. package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +31 -25
  7. package/dist/cjs/src/dream/Query.js +96 -88
  8. package/dist/cjs/src/dream/internal/associations/associationQuery.js +3 -3
  9. package/dist/cjs/src/dream/internal/associations/associationUpdateQuery.js +3 -3
  10. package/dist/cjs/src/dream/internal/associations/destroyAssociation.js +2 -2
  11. package/dist/cjs/src/dream/internal/associations/undestroyAssociation.js +2 -2
  12. package/dist/cjs/src/dream/internal/similarity/SimilarityBuilder.js +12 -12
  13. package/dist/cjs/src/errors/{CannotDefineAssociationWithBothDependentAndRequiredOnClause.js → CannotDefineAssociationWithBothDependentAndRequiredAndClause.js} +2 -2
  14. package/dist/cjs/src/errors/associations/{MissingRequiredAssociationOnClause.js → MissingRequiredAssociationAndClause.js} +4 -4
  15. package/dist/cjs/src/errors/associations/MissingRequiredPassthroughForAssociationAndClause.js +16 -0
  16. package/dist/cjs/src/helpers/cli/SchemaBuilder.js +1 -1
  17. package/dist/esm/src/Dream.js +42 -32
  18. package/dist/esm/src/decorators/field/association/HasMany.js +12 -12
  19. package/dist/esm/src/decorators/field/association/HasOne.js +12 -12
  20. package/dist/esm/src/decorators/field/association/shared.js +7 -7
  21. package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +31 -25
  22. package/dist/esm/src/dream/Query.js +96 -88
  23. package/dist/esm/src/dream/internal/associations/associationQuery.js +3 -3
  24. package/dist/esm/src/dream/internal/associations/associationUpdateQuery.js +3 -3
  25. package/dist/esm/src/dream/internal/associations/destroyAssociation.js +2 -2
  26. package/dist/esm/src/dream/internal/associations/undestroyAssociation.js +2 -2
  27. package/dist/esm/src/dream/internal/similarity/SimilarityBuilder.js +12 -12
  28. package/dist/esm/src/errors/{CannotDefineAssociationWithBothDependentAndRequiredOnClause.js → CannotDefineAssociationWithBothDependentAndRequiredAndClause.js} +1 -1
  29. package/dist/esm/src/errors/associations/{MissingRequiredAssociationOnClause.js → MissingRequiredAssociationAndClause.js} +3 -3
  30. package/dist/esm/src/errors/associations/MissingRequiredPassthroughForAssociationAndClause.js +13 -0
  31. package/dist/esm/src/helpers/cli/SchemaBuilder.js +1 -1
  32. package/dist/types/src/Dream.d.ts +25 -21
  33. package/dist/types/src/decorators/field/association/shared.d.ts +2 -2
  34. package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +11 -11
  35. package/dist/types/src/dream/Query.d.ts +15 -15
  36. package/dist/types/src/dream/internal/associations/associationQuery.d.ts +3 -3
  37. package/dist/types/src/dream/internal/associations/associationUpdateQuery.d.ts +3 -3
  38. package/dist/types/src/dream/internal/associations/destroyAssociation.d.ts +3 -3
  39. package/dist/types/src/dream/internal/associations/undestroyAssociation.d.ts +3 -3
  40. package/dist/types/src/dream/internal/similarity/SimilarityBuilder.d.ts +5 -5
  41. package/dist/types/src/errors/{CannotDefineAssociationWithBothDependentAndRequiredOnClause.d.ts → CannotDefineAssociationWithBothDependentAndRequiredAndClause.d.ts} +1 -1
  42. package/dist/types/src/errors/associations/{MissingRequiredAssociationOnClause.d.ts → MissingRequiredAssociationAndClause.d.ts} +1 -1
  43. package/dist/types/src/errors/associations/MissingRequiredPassthroughForAssociationAndClause.d.ts +5 -0
  44. package/dist/types/src/types/associations/shared.d.ts +16 -14
  45. package/dist/types/src/types/dream.d.ts +15 -15
  46. package/dist/types/src/types/variadic.d.ts +5 -5
  47. package/docs/assets/search.js +1 -1
  48. package/docs/classes/Benchmark.html +2 -2
  49. package/docs/classes/CalendarDate.html +2 -2
  50. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  51. package/docs/classes/Decorators.html +19 -19
  52. package/docs/classes/Dream.html +170 -163
  53. package/docs/classes/DreamApplication.html +4 -4
  54. package/docs/classes/DreamBin.html +2 -2
  55. package/docs/classes/DreamCLI.html +4 -4
  56. package/docs/classes/DreamImporter.html +2 -2
  57. package/docs/classes/DreamLogos.html +2 -2
  58. package/docs/classes/DreamMigrationHelpers.html +7 -7
  59. package/docs/classes/DreamSerializer.html +2 -2
  60. package/docs/classes/DreamTransaction.html +2 -2
  61. package/docs/classes/Encrypt.html +2 -2
  62. package/docs/classes/Env.html +2 -2
  63. package/docs/classes/GlobalNameNotSet.html +3 -3
  64. package/docs/classes/NonLoadedAssociation.html +3 -3
  65. package/docs/classes/Query.html +54 -54
  66. package/docs/classes/Range.html +2 -2
  67. package/docs/classes/RecordNotFound.html +3 -3
  68. package/docs/classes/ValidationError.html +3 -3
  69. package/docs/functions/Attribute.html +1 -1
  70. package/docs/functions/RendersMany.html +1 -1
  71. package/docs/functions/RendersOne.html +1 -1
  72. package/docs/functions/ReplicaSafe.html +1 -1
  73. package/docs/functions/STI.html +1 -1
  74. package/docs/functions/SoftDelete.html +1 -1
  75. package/docs/functions/camelize.html +1 -1
  76. package/docs/functions/capitalize.html +1 -1
  77. package/docs/functions/closeAllDbConnections.html +1 -1
  78. package/docs/functions/compact.html +1 -1
  79. package/docs/functions/debug.html +1 -1
  80. package/docs/functions/dreamDbConnections.html +1 -1
  81. package/docs/functions/dreamPath.html +1 -1
  82. package/docs/functions/generateDream.html +1 -1
  83. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  84. package/docs/functions/hyphenize.html +1 -1
  85. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  86. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  87. package/docs/functions/isEmpty.html +1 -1
  88. package/docs/functions/loadRepl.html +1 -1
  89. package/docs/functions/lookupClassByGlobalName.html +1 -1
  90. package/docs/functions/pascalize.html +1 -1
  91. package/docs/functions/pgErrorType.html +1 -1
  92. package/docs/functions/range-1.html +1 -1
  93. package/docs/functions/relativeDreamPath.html +1 -1
  94. package/docs/functions/round.html +1 -1
  95. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  96. package/docs/functions/sharedPathPrefix.html +1 -1
  97. package/docs/functions/snakeify.html +1 -1
  98. package/docs/functions/sort.html +1 -1
  99. package/docs/functions/sortBy.html +1 -1
  100. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  101. package/docs/functions/uncapitalize.html +1 -1
  102. package/docs/functions/uniq.html +1 -1
  103. package/docs/functions/untypedDb.html +1 -1
  104. package/docs/functions/validateColumn.html +1 -1
  105. package/docs/functions/validateTable.html +1 -1
  106. package/docs/index.html +1 -1
  107. package/docs/interfaces/AttributeStatement.html +2 -2
  108. package/docs/interfaces/DecoratorContext.html +2 -2
  109. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  110. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  111. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  112. package/docs/interfaces/EncryptOptions.html +2 -2
  113. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  114. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  115. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  116. package/docs/types/Camelized.html +1 -1
  117. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  118. package/docs/types/DateTime.html +1 -1
  119. package/docs/types/DbConnectionType.html +1 -1
  120. package/docs/types/DreamAssociationMetadata.html +1 -1
  121. package/docs/types/DreamAttributes.html +1 -1
  122. package/docs/types/DreamClassColumn.html +1 -1
  123. package/docs/types/DreamColumn.html +1 -1
  124. package/docs/types/DreamColumnNames.html +1 -1
  125. package/docs/types/DreamLogLevel.html +1 -1
  126. package/docs/types/DreamLogger.html +1 -1
  127. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  128. package/docs/types/DreamParamSafeAttributes.html +1 -1
  129. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  130. package/docs/types/DreamSerializerKey.html +1 -1
  131. package/docs/types/DreamSerializers.html +1 -1
  132. package/docs/types/DreamTableSchema.html +1 -1
  133. package/docs/types/DreamVirtualColumns.html +1 -1
  134. package/docs/types/EncryptAlgorithm.html +1 -1
  135. package/docs/types/Hyphenized.html +1 -1
  136. package/docs/types/IdType.html +1 -1
  137. package/docs/types/OpenapiAllTypes.html +1 -1
  138. package/docs/types/OpenapiFormats.html +1 -1
  139. package/docs/types/OpenapiNumberFormats.html +1 -1
  140. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  141. package/docs/types/OpenapiSchemaArray.html +1 -1
  142. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  143. package/docs/types/OpenapiSchemaBase.html +1 -1
  144. package/docs/types/OpenapiSchemaBody.html +1 -1
  145. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  146. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  147. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  148. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  149. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  150. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  151. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  152. package/docs/types/OpenapiSchemaInteger.html +1 -1
  153. package/docs/types/OpenapiSchemaNull.html +1 -1
  154. package/docs/types/OpenapiSchemaNumber.html +1 -1
  155. package/docs/types/OpenapiSchemaObject.html +1 -1
  156. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  157. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  158. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  159. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  160. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  161. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  162. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  163. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  164. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  165. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  166. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  167. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  168. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  169. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  170. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  171. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  172. package/docs/types/OpenapiSchemaString.html +1 -1
  173. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  174. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  175. package/docs/types/OpenapiTypeField.html +1 -1
  176. package/docs/types/Pascalized.html +1 -1
  177. package/docs/types/PrimaryKeyType.html +1 -1
  178. package/docs/types/RoundingPrecision.html +1 -1
  179. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  180. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  181. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  182. package/docs/types/SerializableTypes.html +1 -1
  183. package/docs/types/Snakeified.html +1 -1
  184. package/docs/types/Timestamp.html +1 -1
  185. package/docs/types/UpdateableAssociationProperties.html +1 -1
  186. package/docs/types/UpdateableProperties.html +1 -1
  187. package/docs/types/ValidationType.html +1 -1
  188. package/docs/types/ViewModelSerializerKey.html +1 -1
  189. package/docs/types/WhereStatementForDream.html +1 -1
  190. package/docs/types/WhereStatementForDreamClass.html +1 -1
  191. package/docs/variables/DateTime-1.html +1 -1
  192. package/docs/variables/DreamConst.html +1 -1
  193. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  194. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  195. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  196. package/docs/variables/ops.html +1 -1
  197. package/docs/variables/primaryKeyTypes.html +1 -1
  198. package/package.json +1 -1
  199. package/dist/cjs/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.js +0 -16
  200. package/dist/esm/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.js +0 -13
  201. package/dist/types/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.d.ts +0 -5
package/README.md CHANGED
@@ -360,7 +360,7 @@ class B extends A {
360
360
 
361
361
  @STI(A)
362
362
  class C extends A {
363
- @deco.HasMany('X', { on: { something: true } })
363
+ @deco.HasMany('X', { and: { something: true } })
364
364
  public xx: X[]
365
365
  }
366
366
 
@@ -772,11 +772,14 @@ class Dream {
772
772
  }
773
773
  /**
774
774
  * Returns a new instance of Query scoped to the given
775
- * model class
775
+ * model class. Especially useful with {@link Query#toKysely}.
776
776
  *
777
777
  * ```ts
778
- * await User.query().all()
779
- * // [User{id: 1}, User{id: 2}, ...]
778
+ * await Balloon.query().toKysely('update').
779
+ * .set({
780
+ * multicolor: sql`array_remove(multicolor, ${colorToRemoveFromAllBalloons})`,
781
+ * })
782
+ * .execute()
780
783
  * ```
781
784
  *
782
785
  * @returns A new Query instance scoped to this Dream class
@@ -786,17 +789,18 @@ class Dream {
786
789
  return new Query_js_1.default(this.prototype);
787
790
  }
788
791
  /**
789
- * @internal
790
- *
791
792
  * Returns a new instance of Query scoped to the given
792
- * Dream instance
793
+ * model class. Especially useful with {@link Query#toKysely}.
793
794
  *
794
795
  * ```ts
795
- * await user = User.first()
796
- * await user.query()
796
+ * await balloon.query().toKysely('update')
797
+ * .set({
798
+ * multicolor: sql`array_append(multicolor, 'red')`,
799
+ * })
800
+ * .execute()
797
801
  * ```
798
802
  *
799
- * @returns A new Query instance scoped to this Dream instance
803
+ * @returns A new Query instance scoped to this Dream class
800
804
  *
801
805
  */
802
806
  query() {
@@ -2555,7 +2559,9 @@ class Dream {
2555
2559
  *
2556
2560
  * @param associationName - The name of the association to destroy
2557
2561
  * @param options - Options for destroying the association
2558
- * @param options.on - Optional where statement to apply to query before destroying
2562
+ * @param options.and - Optional and statement to apply to query before destroying
2563
+ * @param options.andNot - Optional andNot statement to apply to query before destroying
2564
+ * @param options.andAny - Optional andAny statement to apply to query before destroying
2559
2565
  * @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
2560
2566
  * @param options.cascade - If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true
2561
2567
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
@@ -2567,10 +2573,10 @@ class Dream {
2567
2573
  throw new CannotDestroyAssociationOnUnpersistedDream_js_1.default(this, associationName);
2568
2574
  return await (0, destroyAssociation_js_1.default)(this, null, associationName, {
2569
2575
  ...(0, destroyOptions_js_1.destroyOptions)(options),
2570
- joinOnStatements: {
2571
- on: options?.on,
2572
- notOn: options?.notOn,
2573
- onAny: options?.onAny,
2576
+ joinAndStatements: {
2577
+ and: options?.and,
2578
+ andNot: options?.andNot,
2579
+ andAny: options?.andAny,
2574
2580
  },
2575
2581
  });
2576
2582
  }
@@ -2589,7 +2595,9 @@ class Dream {
2589
2595
  *
2590
2596
  * @param associationName - The name of the association to destroy
2591
2597
  * @param options - Options for destroying the association
2592
- * @param options.on - Optional where statement to apply to query before destroying
2598
+ * @param options.and - Optional and statement to apply to query before destroying
2599
+ * @param options.andNot - Optional andNot statement to apply to query before destroying
2600
+ * @param options.andAny - Optional andAny statement to apply to query before destroying
2593
2601
  * @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
2594
2602
  * @param options.cascade - If true, cascades the destroy operation to associations marked with `dependent: 'destroy'`. Defaults to true
2595
2603
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
@@ -2601,10 +2609,10 @@ class Dream {
2601
2609
  throw new CannotDestroyAssociationOnUnpersistedDream_js_1.default(this, associationName);
2602
2610
  return await (0, destroyAssociation_js_1.default)(this, null, associationName, {
2603
2611
  ...(0, destroyOptions_js_1.reallyDestroyOptions)(options),
2604
- joinOnStatements: {
2605
- on: options?.on,
2606
- notOn: options?.notOn,
2607
- onAny: options?.onAny,
2612
+ joinAndStatements: {
2613
+ and: options?.and,
2614
+ andNot: options?.andNot,
2615
+ andAny: options?.andAny,
2608
2616
  },
2609
2617
  });
2610
2618
  }
@@ -2620,7 +2628,9 @@ class Dream {
2620
2628
  *
2621
2629
  * @param associationName - The name of the association to undestroy
2622
2630
  * @param options - Options for undestroying the association
2623
- * @param options.on - Optional where statement to apply to query before undestroying
2631
+ * @param options.and - Optional and statement to apply to query before undestroying
2632
+ * @param options.andNot - Optional andNot statement to apply to query before undestroying
2633
+ * @param options.andAny - Optional andAny statement to apply to query before undestroying
2624
2634
  * @param options.skipHooks - If true, skips applying model hooks during the undestroy operation. Defaults to false
2625
2635
  * @param options.cascade - If false, skips undestroying associations marked `dependent: 'destroy'`. Defaults to true
2626
2636
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when undestroying the association. Defaults to false
@@ -2630,10 +2640,10 @@ class Dream {
2630
2640
  async undestroyAssociation(associationName, options) {
2631
2641
  return await (0, undestroyAssociation_js_1.default)(this, null, associationName, {
2632
2642
  ...(0, destroyOptions_js_1.undestroyOptions)(options),
2633
- joinOnStatements: {
2634
- on: options?.on,
2635
- notOn: options?.notOn,
2636
- onAny: options?.onAny,
2643
+ joinAndStatements: {
2644
+ and: options?.and,
2645
+ andNot: options?.andNot,
2646
+ andAny: options?.andAny,
2637
2647
  },
2638
2648
  });
2639
2649
  }
@@ -2649,11 +2659,11 @@ class Dream {
2649
2659
  * @returns A Query scoped to the specified association on the current instance
2650
2660
  *
2651
2661
  */
2652
- associationQuery(associationName, joinOnStatements) {
2662
+ associationQuery(associationName, joinAndStatements) {
2653
2663
  if (this.isNewRecord)
2654
2664
  throw new CannotAssociationQueryOnUnpersistedDream_js_1.default(this, associationName);
2655
2665
  return (0, associationQuery_js_1.default)(this, null, associationName, {
2656
- joinOnStatements: joinOnStatements,
2666
+ joinAndStatements: joinAndStatements,
2657
2667
  bypassAllDefaultScopes: scopeHelpers_js_1.DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
2658
2668
  defaultScopesToBypass: scopeHelpers_js_1.DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
2659
2669
  });
@@ -2667,14 +2677,14 @@ class Dream {
2667
2677
  * ```ts
2668
2678
  * await user.createAssociation('posts', { body: 'hello world' })
2669
2679
  * await user.createAssociation('posts', { body: 'howyadoin' })
2670
- * await user.updateAssociation('posts', { body: 'goodbye world' }, { on: { body: 'hello world' }})
2680
+ * await user.updateAssociation('posts', { body: 'goodbye world' }, { and: { body: 'hello world' }})
2671
2681
  * // 1
2672
2682
  * ```
2673
2683
  *
2674
2684
  * @param associationName - The name of the association to update
2675
2685
  * @param attributes - The attributes to update on the association
2676
2686
  * @param options - Options for updating the association
2677
- * @param options.on - Optional on statement to apply to query before updating
2687
+ * @param options.and - Optional on statement to apply to query before updating
2678
2688
  * @param options.skipHooks - If true, skips applying model hooks during the update operation. Defaults to false
2679
2689
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when updating the association. Defaults to false
2680
2690
  * @param options.defaultScopesToBypass - An array of default scope names to bypass when updating the association. Defaults to an empty array
@@ -2684,10 +2694,10 @@ class Dream {
2684
2694
  if (this.isNewRecord)
2685
2695
  throw new CannotUpdateAssociationOnUnpersistedDream_js_1.default(this, associationName);
2686
2696
  return (0, associationUpdateQuery_js_1.default)(this, null, associationName, {
2687
- joinOnStatements: {
2688
- on: updateAssociationOptions?.on,
2689
- notOn: updateAssociationOptions?.notOn,
2690
- onAny: updateAssociationOptions?.onAny,
2697
+ joinAndStatements: {
2698
+ and: updateAssociationOptions?.and,
2699
+ andNot: updateAssociationOptions?.andNot,
2700
+ andAny: updateAssociationOptions?.andAny,
2691
2701
  },
2692
2702
  bypassAllDefaultScopes: updateAssociationOptions?.bypassAllDefaultScopes ?? scopeHelpers_js_1.DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
2693
2703
  defaultScopesToBypass: updateAssociationOptions?.defaultScopesToBypass ?? scopeHelpers_js_1.DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
@@ -24,21 +24,21 @@ const shared_js_1 = require("./shared.js");
24
24
  * @param opts.dependent - Can be either "destroy" or undefined. If "destroy", this record will be cascade deleted if the base model is destroyed.
25
25
  * @param opts.distinct - Can be a column name, or else a boolean. If a column name, a distinct clause will be applied to the column. If true, a distinct clause will be applied to the primary key.
26
26
  * @param opts.foreignKey - A custom column name to use for the foreign key.
27
- * @param opts.on - An on clause to be applied when this association is loaded
28
- * @param opts.notOn - A not on clause to be applied when this association is loaded
29
- * @param opts.onAny - An onAny clause to be applied when this association is loaded
27
+ * @param opts.and - An and-clause to be applied when this association is loaded
28
+ * @param opts.andNot - A not and-clause to be applied when this association is loaded
29
+ * @param opts.andAny - An andAny clause to be applied when this association is loaded
30
30
  * @param opts.order - A custom order statement to apply to this association.
31
31
  * @param opts.polymorphic - If true, this association will be treated as a polymorphic association.
32
32
  * @param opts.preloadThroughColumns - An array of columns to pluck off the through association attached to this association. Can only be set if `through` is also set.
33
33
  * @param opts.primaryKeyOverride - A custom column name to use for the primary key.
34
- * @param opts.selfOn - Adds an on clause to an association between a column on the associated model and a column on this model.
35
- * @param opts.selfNotOn - Adds a not on clause to an association between a column on the associated model and a column on this model.
34
+ * @param opts.selfAnd - Adds an and-clause to an association between a column on the associated model and a column on this model.
35
+ * @param opts.selfAndNot - Adds a not and-clause to an association between a column on the associated model and a column on this model.
36
36
  * @param opts.source - Used in conjunction with 'through' to specify the source association on a child model.
37
37
  * @param opts.through - If passed, this association will travel through another association.
38
38
  * @param opts.withoutDefaultScopes - A list of default scopes to bypass when loading this association
39
39
  */
40
40
  function HasMany(globalAssociationNameOrNames, opts = {}) {
41
- const { dependent, distinct, foreignKey, on, notOn, onAny, order, polymorphic = false, preloadThroughColumns, primaryKeyOverride = null, selfOn, selfNotOn, source, through, withoutDefaultScopes, } = opts;
41
+ const { dependent, distinct, foreignKey, and, andNot, andAny, order, polymorphic = false, preloadThroughColumns, primaryKeyOverride = null, selfAnd, selfAndNot, source, through, withoutDefaultScopes, } = opts;
42
42
  return function (_, context) {
43
43
  const key = context.name;
44
44
  context.addInitializer(function () {
@@ -60,21 +60,21 @@ function HasMany(globalAssociationNameOrNames, opts = {}) {
60
60
  dreamClass,
61
61
  dependent: dependent ?? null,
62
62
  methodName: key,
63
- on: on ?? null,
63
+ and: and ?? null,
64
64
  });
65
65
  const partialAssociation = (0, shared_js_1.associationPrimaryKeyAccessors)({
66
66
  modelCB: () => (0, lookupModelByGlobalNameOrNames_js_1.default)(globalAssociationNameOrNames),
67
67
  as: key,
68
68
  dependent,
69
69
  globalAssociationNameOrNames,
70
- on,
71
- notOn,
72
- onAny,
70
+ and,
71
+ andNot,
72
+ andAny,
73
73
  polymorphic,
74
74
  preloadThroughColumns,
75
75
  primaryKeyOverride,
76
- selfOn,
77
- selfNotOn,
76
+ selfAnd,
77
+ selfAndNot,
78
78
  source: source || key,
79
79
  type: 'HasMany',
80
80
  withoutDefaultScopes,
@@ -23,20 +23,20 @@ const shared_js_1 = require("./shared.js");
23
23
  *
24
24
  * @param opts.dependent - Can be either "destroy" or undefined. If "destroy", this record will be cascade deleted if the base model is destroyed.
25
25
  * @param opts.foreignKey - A custom column name to use for the foreign key.
26
- * @param opts.on - An on clause to be applied when this association is loaded
27
- * @param opts.notOn - A not on clause to be applied when this association is loaded
28
- * @param opts.onAny - An onAny clause to be applied when this association is loaded
26
+ * @param opts.and - An and-clause to be applied when this association is loaded
27
+ * @param opts.andNot - A not and-clause to be applied when this association is loaded
28
+ * @param opts.andAny - An andAny clause to be applied when this association is loaded
29
29
  * @param opts.polymorphic - If true, this association will be treated as a polymorphic association.
30
30
  * @param opts.preloadThroughColumns - An array of columns to pluck off the through association attached to this association. Can only be set if `through` is also set.
31
31
  * @param opts.primaryKeyOverride - A custom column name to use for the primary key.
32
- * @param opts.selfOn - Adds an on clause to an association between a column on the associated model and a column on this model.
33
- * @param opts.selfNotOn - Adds a not on clause to an association between a column on the associated model and a column on this model.
32
+ * @param opts.selfAnd - Adds an and-clause to an association between a column on the associated model and a column on this model.
33
+ * @param opts.selfAndNot - Adds a not and-clause to an association between a column on the associated model and a column on this model.
34
34
  * @param opts.source - Used in conjunction with 'through' to specify the source association on a child model.
35
35
  * @param opts.through - If passed, this association will travel through another association.
36
36
  * @param opts.withoutDefaultScopes - A list of default scopes to bypass when loading this association
37
37
  */
38
38
  function HasOne(globalAssociationNameOrNames, opts = {}) {
39
- const { dependent, foreignKey, on, notOn, onAny, polymorphic = false, preloadThroughColumns, primaryKeyOverride = null, selfOn, selfNotOn, source, through, withoutDefaultScopes, } = opts;
39
+ const { dependent, foreignKey, and, andNot, andAny, polymorphic = false, preloadThroughColumns, primaryKeyOverride = null, selfAnd, selfAndNot, source, through, withoutDefaultScopes, } = opts;
40
40
  return function (_, context) {
41
41
  const key = context.name;
42
42
  context.addInitializer(function () {
@@ -58,21 +58,21 @@ function HasOne(globalAssociationNameOrNames, opts = {}) {
58
58
  dreamClass,
59
59
  dependent: dependent ?? null,
60
60
  methodName: key,
61
- on: on ?? null,
61
+ and: and ?? null,
62
62
  });
63
63
  const partialAssociation = (0, shared_js_1.associationPrimaryKeyAccessors)({
64
64
  modelCB: () => (0, lookupModelByGlobalNameOrNames_js_1.default)(globalAssociationNameOrNames),
65
65
  as: key,
66
66
  dependent,
67
67
  globalAssociationNameOrNames,
68
- on,
69
- notOn,
70
- onAny,
68
+ and,
69
+ andNot,
70
+ andAny,
71
71
  polymorphic,
72
72
  preloadThroughColumns,
73
73
  primaryKeyOverride,
74
- selfOn,
75
- selfNotOn,
74
+ selfAnd,
75
+ selfAndNot,
76
76
  source: source || key,
77
77
  through,
78
78
  type: 'HasOne',
@@ -12,7 +12,7 @@ const constants_js_1 = require("../../../dream/constants.js");
12
12
  const InvalidComputedForeignKey_js_1 = require("../../../errors/associations/InvalidComputedForeignKey.js");
13
13
  const NonLoadedAssociation_js_1 = require("../../../errors/associations/NonLoadedAssociation.js");
14
14
  const CannotDefineAssociationWithBothDependentAndPassthrough_js_1 = require("../../../errors/CannotDefineAssociationWithBothDependentAndPassthrough.js");
15
- const CannotDefineAssociationWithBothDependentAndRequiredOnClause_js_1 = require("../../../errors/CannotDefineAssociationWithBothDependentAndRequiredOnClause.js");
15
+ const CannotDefineAssociationWithBothDependentAndRequiredAndClause_js_1 = require("../../../errors/CannotDefineAssociationWithBothDependentAndRequiredAndClause.js");
16
16
  const camelize_js_1 = require("../../../helpers/camelize.js");
17
17
  const freezeBaseClassArrayMap_js_1 = require("../../helpers/freezeBaseClassArrayMap.js");
18
18
  const associationToGetterSetterProp_js_1 = require("./associationToGetterSetterProp.js");
@@ -122,11 +122,11 @@ association: ${this.as}
122
122
  },
123
123
  };
124
124
  }
125
- function validateHasStatementArgs({ dreamClass, dependent, methodName, on, }) {
126
- const hasPassthroughOn = Object.values(on || {}).find(val => val === constants_js_1.DreamConst.passthrough);
127
- const hasRequiredOn = Object.values(on || {}).find(val => val === constants_js_1.DreamConst.required);
128
- if (dependent && hasPassthroughOn)
125
+ function validateHasStatementArgs({ dreamClass, dependent, methodName, and, }) {
126
+ const hasPassthroughAnd = Object.values(and || {}).find(val => val === constants_js_1.DreamConst.passthrough);
127
+ const hasRequiredAnd = Object.values(and || {}).find(val => val === constants_js_1.DreamConst.required);
128
+ if (dependent && hasPassthroughAnd)
129
129
  throw new CannotDefineAssociationWithBothDependentAndPassthrough_js_1.default(dreamClass, methodName);
130
- if (dependent && hasRequiredOn)
131
- throw new CannotDefineAssociationWithBothDependentAndRequiredOnClause_js_1.default(dreamClass, methodName);
130
+ if (dependent && hasRequiredAnd)
131
+ throw new CannotDefineAssociationWithBothDependentAndRequiredAndClause_js_1.default(dreamClass, methodName);
132
132
  }
@@ -313,11 +313,11 @@ class DreamInstanceTransactionBuilder {
313
313
  *
314
314
  * @returns A Query scoped to the specified association on the current instance
315
315
  */
316
- associationQuery(associationName, joinOnStatements) {
316
+ associationQuery(associationName, joinAndStatements) {
317
317
  if (this.dreamInstance.isNewRecord)
318
318
  throw new CannotAssociationQueryOnUnpersistedDream_js_1.default(this.dreamInstance, associationName);
319
319
  return (0, associationQuery_js_1.default)(this.dreamInstance, this.dreamTransaction, associationName, {
320
- joinOnStatements: joinOnStatements,
320
+ joinAndStatements: joinAndStatements,
321
321
  bypassAllDefaultScopes: scopeHelpers_js_1.DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
322
322
  defaultScopesToBypass: scopeHelpers_js_1.DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
323
323
  });
@@ -332,7 +332,7 @@ class DreamInstanceTransactionBuilder {
332
332
  * await ApplicationModel.transaction(async txn => {
333
333
  * await user.txn(txn).createAssociation('posts', { body: 'hello world' })
334
334
  * await user.txn(txn).createAssociation('posts', { body: 'howyadoin' })
335
- * await user.txn(txn).updateAssociation('posts', { body: 'goodbye world' }, { on: { body: 'hello world' }})
335
+ * await user.txn(txn).updateAssociation('posts', { body: 'goodbye world' }, { and: { body: 'hello world' }})
336
336
  * // 1
337
337
  * })
338
338
  * ```
@@ -350,10 +350,10 @@ class DreamInstanceTransactionBuilder {
350
350
  if (this.dreamInstance.isNewRecord)
351
351
  throw new CannotUpdateAssociationOnUnpersistedDream_js_1.default(this.dreamInstance, associationName);
352
352
  return await (0, associationUpdateQuery_js_1.default)(this.dreamInstance, this.dreamTransaction, associationName, {
353
- joinOnStatements: {
354
- on: updateAssociationOptions?.on,
355
- notOn: updateAssociationOptions?.notOn,
356
- onAny: updateAssociationOptions?.onAny,
353
+ joinAndStatements: {
354
+ and: updateAssociationOptions?.and,
355
+ andNot: updateAssociationOptions?.andNot,
356
+ andAny: updateAssociationOptions?.andAny,
357
357
  },
358
358
  bypassAllDefaultScopes: updateAssociationOptions?.bypassAllDefaultScopes ?? scopeHelpers_js_1.DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
359
359
  defaultScopesToBypass: updateAssociationOptions?.defaultScopesToBypass ?? scopeHelpers_js_1.DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
@@ -385,13 +385,15 @@ class DreamInstanceTransactionBuilder {
385
385
  *
386
386
  * ```ts
387
387
  * await ApplicationModel.transaction(async txn => {
388
- * await user.txn(txn).destroyAssociation('posts', { on: { body: 'hello world' } })
388
+ * await user.txn(txn).destroyAssociation('posts', { and: { body: 'hello world' } })
389
389
  * })
390
390
  * ```
391
391
  *
392
392
  * @param associationName - The name of the association to destroy
393
393
  * @param options - Options for destroying the association
394
- * @param options.on - Optional where statement to apply to query before destroying
394
+ * @param options.and - Optional and statement to apply to query before destroying
395
+ * @param options.andNot - Optional andNot statement to apply to query before destroying
396
+ * @param options.andAny - Optional andAny statement to apply to query before destroying
395
397
  * @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
396
398
  * @param options.cascade - If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true
397
399
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
@@ -403,10 +405,10 @@ class DreamInstanceTransactionBuilder {
403
405
  throw new CannotDestroyAssociationOnUnpersistedDream_js_1.default(this.dreamInstance, associationName);
404
406
  return await (0, destroyAssociation_js_1.default)(this.dreamInstance, this.dreamTransaction, associationName, {
405
407
  ...(0, destroyOptions_js_1.destroyOptions)(options),
406
- joinOnStatements: {
407
- on: options?.on,
408
- notOn: options?.notOn,
409
- onAny: options?.onAny,
408
+ joinAndStatements: {
409
+ and: options?.and,
410
+ andNot: options?.andNot,
411
+ andAny: options?.andAny,
410
412
  },
411
413
  });
412
414
  }
@@ -421,13 +423,15 @@ class DreamInstanceTransactionBuilder {
421
423
  *
422
424
  * ```ts
423
425
  * await ApplicationModel.transaction(async txn => {
424
- * await user.txn(txn).reallyDestroyAssociation('posts', { on: { body: 'hello world' } })
426
+ * await user.txn(txn).reallyDestroyAssociation('posts', { and: { body: 'hello world' } })
425
427
  * })
426
428
  * ```
427
429
  *
428
430
  * @param associationName - The name of the association to destroy
429
431
  * @param options - Options for destroying the association
430
- * @param options.on - Optional where statement to apply to query before destroying
432
+ * @param options.and - Optional and statement to apply to query before destroying
433
+ * @param options.andNot - Optional andNot statement to apply to query before destroying
434
+ * @param options.andAny - Optional andAny statement to apply to query before destroying
431
435
  * @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
432
436
  * @param options.cascade - If true, cascades the destroy operation to associations marked with `dependent: 'destroy'`. Defaults to true
433
437
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
@@ -439,10 +443,10 @@ class DreamInstanceTransactionBuilder {
439
443
  throw new CannotDestroyAssociationOnUnpersistedDream_js_1.default(this.dreamInstance, associationName);
440
444
  return await (0, destroyAssociation_js_1.default)(this.dreamInstance, this.dreamTransaction, associationName, {
441
445
  ...(0, destroyOptions_js_1.reallyDestroyOptions)(options),
442
- joinOnStatements: {
443
- on: options?.on,
444
- notOn: options?.notOn,
445
- onAny: options?.onAny,
446
+ joinAndStatements: {
447
+ and: options?.and,
448
+ andNot: options?.andNot,
449
+ andAny: options?.andAny,
446
450
  },
447
451
  });
448
452
  }
@@ -453,12 +457,14 @@ class DreamInstanceTransactionBuilder {
453
457
  * will also be undeleted.
454
458
  *
455
459
  * ```ts
456
- * await user.undestroyAssociation('posts', { on: { body: 'hello world' } })
460
+ * await user.undestroyAssociation('posts', { and: { body: 'hello world' } })
457
461
  * ```
458
462
  *
459
463
  * @param associationName - The name of the association to undestroy
460
464
  * @param options - Options for undestroying the association
461
- * @param options.on - Optional where statement to apply to query before undestroying
465
+ * @param options.and - Optional and statement to apply to query before undestroying
466
+ * @param options.andNot - Optional andNot statement to apply to query before undestroying
467
+ * @param options.andAny - Optional andAny statement to apply to query before undestroying
462
468
  * @param options.skipHooks - If true, skips applying model hooks during the undestroy operation. Defaults to false
463
469
  * @param options.cascade - If false, skips undestroying associations marked `dependent: 'destroy'`. Defaults to true
464
470
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when undestroying the association. Defaults to false
@@ -468,10 +474,10 @@ class DreamInstanceTransactionBuilder {
468
474
  async undestroyAssociation(associationName, options) {
469
475
  return await (0, undestroyAssociation_js_1.default)(this.dreamInstance, this.dreamTransaction, associationName, {
470
476
  ...(0, destroyOptions_js_1.undestroyOptions)(options),
471
- joinOnStatements: {
472
- on: options?.on,
473
- notOn: options?.notOn,
474
- onAny: options?.onAny,
477
+ joinAndStatements: {
478
+ and: options?.and,
479
+ andNot: options?.andNot,
480
+ andAny: options?.andAny,
475
481
  },
476
482
  });
477
483
  }