@rvoh/dream 0.36.4 → 0.37.4

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 (200) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/src/Dream.js +29 -23
  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 +29 -23
  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 +11 -11
  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/classes/Benchmark.html +2 -2
  48. package/docs/classes/CalendarDate.html +2 -2
  49. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  50. package/docs/classes/Decorators.html +19 -19
  51. package/docs/classes/Dream.html +126 -126
  52. package/docs/classes/DreamApplication.html +4 -4
  53. package/docs/classes/DreamBin.html +2 -2
  54. package/docs/classes/DreamCLI.html +4 -4
  55. package/docs/classes/DreamImporter.html +2 -2
  56. package/docs/classes/DreamLogos.html +2 -2
  57. package/docs/classes/DreamMigrationHelpers.html +7 -7
  58. package/docs/classes/DreamSerializer.html +2 -2
  59. package/docs/classes/DreamTransaction.html +2 -2
  60. package/docs/classes/Encrypt.html +2 -2
  61. package/docs/classes/Env.html +2 -2
  62. package/docs/classes/GlobalNameNotSet.html +3 -3
  63. package/docs/classes/NonLoadedAssociation.html +3 -3
  64. package/docs/classes/Query.html +54 -54
  65. package/docs/classes/Range.html +2 -2
  66. package/docs/classes/RecordNotFound.html +3 -3
  67. package/docs/classes/ValidationError.html +3 -3
  68. package/docs/functions/Attribute.html +1 -1
  69. package/docs/functions/RendersMany.html +1 -1
  70. package/docs/functions/RendersOne.html +1 -1
  71. package/docs/functions/ReplicaSafe.html +1 -1
  72. package/docs/functions/STI.html +1 -1
  73. package/docs/functions/SoftDelete.html +1 -1
  74. package/docs/functions/camelize.html +1 -1
  75. package/docs/functions/capitalize.html +1 -1
  76. package/docs/functions/closeAllDbConnections.html +1 -1
  77. package/docs/functions/compact.html +1 -1
  78. package/docs/functions/debug.html +1 -1
  79. package/docs/functions/dreamDbConnections.html +1 -1
  80. package/docs/functions/dreamPath.html +1 -1
  81. package/docs/functions/generateDream.html +1 -1
  82. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  83. package/docs/functions/hyphenize.html +1 -1
  84. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  85. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  86. package/docs/functions/isEmpty.html +1 -1
  87. package/docs/functions/loadRepl.html +1 -1
  88. package/docs/functions/lookupClassByGlobalName.html +1 -1
  89. package/docs/functions/pascalize.html +1 -1
  90. package/docs/functions/pgErrorType.html +1 -1
  91. package/docs/functions/range-1.html +1 -1
  92. package/docs/functions/relativeDreamPath.html +1 -1
  93. package/docs/functions/round.html +1 -1
  94. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  95. package/docs/functions/sharedPathPrefix.html +1 -1
  96. package/docs/functions/snakeify.html +1 -1
  97. package/docs/functions/sort.html +1 -1
  98. package/docs/functions/sortBy.html +1 -1
  99. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  100. package/docs/functions/uncapitalize.html +1 -1
  101. package/docs/functions/uniq.html +1 -1
  102. package/docs/functions/untypedDb.html +1 -1
  103. package/docs/functions/validateColumn.html +1 -1
  104. package/docs/functions/validateTable.html +1 -1
  105. package/docs/index.html +1 -1
  106. package/docs/interfaces/AttributeStatement.html +2 -2
  107. package/docs/interfaces/DecoratorContext.html +2 -2
  108. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  109. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  110. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  111. package/docs/interfaces/EncryptOptions.html +2 -2
  112. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  113. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  114. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  115. package/docs/types/Camelized.html +1 -1
  116. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  117. package/docs/types/DateTime.html +1 -1
  118. package/docs/types/DbConnectionType.html +1 -1
  119. package/docs/types/DreamAssociationMetadata.html +1 -1
  120. package/docs/types/DreamAttributes.html +1 -1
  121. package/docs/types/DreamClassColumn.html +1 -1
  122. package/docs/types/DreamColumn.html +1 -1
  123. package/docs/types/DreamColumnNames.html +1 -1
  124. package/docs/types/DreamLogLevel.html +1 -1
  125. package/docs/types/DreamLogger.html +1 -1
  126. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  127. package/docs/types/DreamParamSafeAttributes.html +1 -1
  128. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  129. package/docs/types/DreamSerializerKey.html +1 -1
  130. package/docs/types/DreamSerializers.html +1 -1
  131. package/docs/types/DreamTableSchema.html +1 -1
  132. package/docs/types/DreamVirtualColumns.html +1 -1
  133. package/docs/types/EncryptAlgorithm.html +1 -1
  134. package/docs/types/Hyphenized.html +1 -1
  135. package/docs/types/IdType.html +1 -1
  136. package/docs/types/OpenapiAllTypes.html +1 -1
  137. package/docs/types/OpenapiFormats.html +1 -1
  138. package/docs/types/OpenapiNumberFormats.html +1 -1
  139. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  140. package/docs/types/OpenapiSchemaArray.html +1 -1
  141. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  142. package/docs/types/OpenapiSchemaBase.html +1 -1
  143. package/docs/types/OpenapiSchemaBody.html +1 -1
  144. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  145. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  146. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  147. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  148. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  149. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  150. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  151. package/docs/types/OpenapiSchemaInteger.html +1 -1
  152. package/docs/types/OpenapiSchemaNull.html +1 -1
  153. package/docs/types/OpenapiSchemaNumber.html +1 -1
  154. package/docs/types/OpenapiSchemaObject.html +1 -1
  155. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  156. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  157. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  158. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  159. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  160. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  161. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  162. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  163. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  164. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  165. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  166. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  167. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  168. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  169. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  170. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  171. package/docs/types/OpenapiSchemaString.html +1 -1
  172. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  173. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  174. package/docs/types/OpenapiTypeField.html +1 -1
  175. package/docs/types/Pascalized.html +1 -1
  176. package/docs/types/PrimaryKeyType.html +1 -1
  177. package/docs/types/RoundingPrecision.html +1 -1
  178. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  179. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  180. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  181. package/docs/types/SerializableTypes.html +1 -1
  182. package/docs/types/Snakeified.html +1 -1
  183. package/docs/types/Timestamp.html +1 -1
  184. package/docs/types/UpdateableAssociationProperties.html +1 -1
  185. package/docs/types/UpdateableProperties.html +1 -1
  186. package/docs/types/ValidationType.html +1 -1
  187. package/docs/types/ViewModelSerializerKey.html +1 -1
  188. package/docs/types/WhereStatementForDream.html +1 -1
  189. package/docs/types/WhereStatementForDreamClass.html +1 -1
  190. package/docs/variables/DateTime-1.html +1 -1
  191. package/docs/variables/DreamConst.html +1 -1
  192. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  193. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  194. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  195. package/docs/variables/ops.html +1 -1
  196. package/docs/variables/primaryKeyTypes.html +1 -1
  197. package/package.json +1 -1
  198. package/dist/cjs/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.js +0 -16
  199. package/dist/esm/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.js +0 -13
  200. package/dist/types/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.d.ts +0 -5
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class MissingRequiredPassthroughForAssociationAndClause extends Error {
4
+ column;
5
+ constructor(column) {
6
+ super();
7
+ this.column = column;
8
+ }
9
+ get message() {
10
+ return `
11
+ Missing passthrough for association and-clause:
12
+ Missing passthrough and-clause for column: ${this.column}
13
+ `;
14
+ }
15
+ }
16
+ exports.default = MissingRequiredPassthroughForAssociationAndClause;
@@ -259,7 +259,7 @@ may need to update the table getter in the corresponding Dream.
259
259
  throw new FailedToIdentifyAssociation_js_1.default(model, associationMetaData.type, associationName, associationMetaData.globalAssociationNameOrNames);
260
260
  const optional = associationMetaData.type === 'BelongsTo' ? associationMetaData.optional === true : null;
261
261
  const where = associationMetaData.type === 'HasMany' || associationMetaData.type === 'HasOne'
262
- ? associationMetaData.on || null
262
+ ? associationMetaData.and || null
263
263
  : null;
264
264
  // NOTE
265
265
  // this try-catch is here because the SchemaBuilder currently needs to be run twice to generate foreignKey
@@ -2553,7 +2553,9 @@ export default class Dream {
2553
2553
  *
2554
2554
  * @param associationName - The name of the association to destroy
2555
2555
  * @param options - Options for destroying the association
2556
- * @param options.on - Optional where statement to apply to query before destroying
2556
+ * @param options.and - Optional and statement to apply to query before destroying
2557
+ * @param options.andNot - Optional andNot statement to apply to query before destroying
2558
+ * @param options.andAny - Optional andAny statement to apply to query before destroying
2557
2559
  * @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
2558
2560
  * @param options.cascade - If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true
2559
2561
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
@@ -2565,10 +2567,10 @@ export default class Dream {
2565
2567
  throw new CannotDestroyAssociationOnUnpersistedDream(this, associationName);
2566
2568
  return await destroyAssociation(this, null, associationName, {
2567
2569
  ...destroyOptions(options),
2568
- joinOnStatements: {
2569
- on: options?.on,
2570
- notOn: options?.notOn,
2571
- onAny: options?.onAny,
2570
+ joinAndStatements: {
2571
+ and: options?.and,
2572
+ andNot: options?.andNot,
2573
+ andAny: options?.andAny,
2572
2574
  },
2573
2575
  });
2574
2576
  }
@@ -2587,7 +2589,9 @@ export default class Dream {
2587
2589
  *
2588
2590
  * @param associationName - The name of the association to destroy
2589
2591
  * @param options - Options for destroying the association
2590
- * @param options.on - Optional where statement to apply to query before destroying
2592
+ * @param options.and - Optional and statement to apply to query before destroying
2593
+ * @param options.andNot - Optional andNot statement to apply to query before destroying
2594
+ * @param options.andAny - Optional andAny statement to apply to query before destroying
2591
2595
  * @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
2592
2596
  * @param options.cascade - If true, cascades the destroy operation to associations marked with `dependent: 'destroy'`. Defaults to true
2593
2597
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
@@ -2599,10 +2603,10 @@ export default class Dream {
2599
2603
  throw new CannotDestroyAssociationOnUnpersistedDream(this, associationName);
2600
2604
  return await destroyAssociation(this, null, associationName, {
2601
2605
  ...reallyDestroyOptions(options),
2602
- joinOnStatements: {
2603
- on: options?.on,
2604
- notOn: options?.notOn,
2605
- onAny: options?.onAny,
2606
+ joinAndStatements: {
2607
+ and: options?.and,
2608
+ andNot: options?.andNot,
2609
+ andAny: options?.andAny,
2606
2610
  },
2607
2611
  });
2608
2612
  }
@@ -2618,7 +2622,9 @@ export default class Dream {
2618
2622
  *
2619
2623
  * @param associationName - The name of the association to undestroy
2620
2624
  * @param options - Options for undestroying the association
2621
- * @param options.on - Optional where statement to apply to query before undestroying
2625
+ * @param options.and - Optional and statement to apply to query before undestroying
2626
+ * @param options.andNot - Optional andNot statement to apply to query before undestroying
2627
+ * @param options.andAny - Optional andAny statement to apply to query before undestroying
2622
2628
  * @param options.skipHooks - If true, skips applying model hooks during the undestroy operation. Defaults to false
2623
2629
  * @param options.cascade - If false, skips undestroying associations marked `dependent: 'destroy'`. Defaults to true
2624
2630
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when undestroying the association. Defaults to false
@@ -2628,10 +2634,10 @@ export default class Dream {
2628
2634
  async undestroyAssociation(associationName, options) {
2629
2635
  return await undestroyAssociation(this, null, associationName, {
2630
2636
  ...undestroyOptions(options),
2631
- joinOnStatements: {
2632
- on: options?.on,
2633
- notOn: options?.notOn,
2634
- onAny: options?.onAny,
2637
+ joinAndStatements: {
2638
+ and: options?.and,
2639
+ andNot: options?.andNot,
2640
+ andAny: options?.andAny,
2635
2641
  },
2636
2642
  });
2637
2643
  }
@@ -2647,11 +2653,11 @@ export default class Dream {
2647
2653
  * @returns A Query scoped to the specified association on the current instance
2648
2654
  *
2649
2655
  */
2650
- associationQuery(associationName, joinOnStatements) {
2656
+ associationQuery(associationName, joinAndStatements) {
2651
2657
  if (this.isNewRecord)
2652
2658
  throw new CannotAssociationQueryOnUnpersistedDream(this, associationName);
2653
2659
  return associationQuery(this, null, associationName, {
2654
- joinOnStatements: joinOnStatements,
2660
+ joinAndStatements: joinAndStatements,
2655
2661
  bypassAllDefaultScopes: DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
2656
2662
  defaultScopesToBypass: DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
2657
2663
  });
@@ -2665,14 +2671,14 @@ export default class Dream {
2665
2671
  * ```ts
2666
2672
  * await user.createAssociation('posts', { body: 'hello world' })
2667
2673
  * await user.createAssociation('posts', { body: 'howyadoin' })
2668
- * await user.updateAssociation('posts', { body: 'goodbye world' }, { on: { body: 'hello world' }})
2674
+ * await user.updateAssociation('posts', { body: 'goodbye world' }, { and: { body: 'hello world' }})
2669
2675
  * // 1
2670
2676
  * ```
2671
2677
  *
2672
2678
  * @param associationName - The name of the association to update
2673
2679
  * @param attributes - The attributes to update on the association
2674
2680
  * @param options - Options for updating the association
2675
- * @param options.on - Optional on statement to apply to query before updating
2681
+ * @param options.and - Optional on statement to apply to query before updating
2676
2682
  * @param options.skipHooks - If true, skips applying model hooks during the update operation. Defaults to false
2677
2683
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when updating the association. Defaults to false
2678
2684
  * @param options.defaultScopesToBypass - An array of default scope names to bypass when updating the association. Defaults to an empty array
@@ -2682,10 +2688,10 @@ export default class Dream {
2682
2688
  if (this.isNewRecord)
2683
2689
  throw new CannotUpdateAssociationOnUnpersistedDream(this, associationName);
2684
2690
  return associationUpdateQuery(this, null, associationName, {
2685
- joinOnStatements: {
2686
- on: updateAssociationOptions?.on,
2687
- notOn: updateAssociationOptions?.notOn,
2688
- onAny: updateAssociationOptions?.onAny,
2691
+ joinAndStatements: {
2692
+ and: updateAssociationOptions?.and,
2693
+ andNot: updateAssociationOptions?.andNot,
2694
+ andAny: updateAssociationOptions?.andAny,
2689
2695
  },
2690
2696
  bypassAllDefaultScopes: updateAssociationOptions?.bypassAllDefaultScopes ?? DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
2691
2697
  defaultScopesToBypass: updateAssociationOptions?.defaultScopesToBypass ?? DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
@@ -21,21 +21,21 @@ import { applyGetterAndSetter, associationPrimaryKeyAccessors, blankAssociations
21
21
  * @param opts.dependent - Can be either "destroy" or undefined. If "destroy", this record will be cascade deleted if the base model is destroyed.
22
22
  * @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.
23
23
  * @param opts.foreignKey - A custom column name to use for the foreign key.
24
- * @param opts.on - An on clause to be applied when this association is loaded
25
- * @param opts.notOn - A not on clause to be applied when this association is loaded
26
- * @param opts.onAny - An onAny clause to be applied when this association is loaded
24
+ * @param opts.and - An and-clause to be applied when this association is loaded
25
+ * @param opts.andNot - A not and-clause to be applied when this association is loaded
26
+ * @param opts.andAny - An andAny clause to be applied when this association is loaded
27
27
  * @param opts.order - A custom order statement to apply to this association.
28
28
  * @param opts.polymorphic - If true, this association will be treated as a polymorphic association.
29
29
  * @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.
30
30
  * @param opts.primaryKeyOverride - A custom column name to use for the primary key.
31
- * @param opts.selfOn - Adds an on clause to an association between a column on the associated model and a column on this model.
32
- * @param opts.selfNotOn - Adds a not on clause to an association between a column on the associated model and a column on this model.
31
+ * @param opts.selfAnd - Adds an and-clause to an association between a column on the associated model and a column on this model.
32
+ * @param opts.selfAndNot - Adds a not and-clause to an association between a column on the associated model and a column on this model.
33
33
  * @param opts.source - Used in conjunction with 'through' to specify the source association on a child model.
34
34
  * @param opts.through - If passed, this association will travel through another association.
35
35
  * @param opts.withoutDefaultScopes - A list of default scopes to bypass when loading this association
36
36
  */
37
37
  export default function HasMany(globalAssociationNameOrNames, opts = {}) {
38
- const { dependent, distinct, foreignKey, on, notOn, onAny, order, polymorphic = false, preloadThroughColumns, primaryKeyOverride = null, selfOn, selfNotOn, source, through, withoutDefaultScopes, } = opts;
38
+ const { dependent, distinct, foreignKey, and, andNot, andAny, order, polymorphic = false, preloadThroughColumns, primaryKeyOverride = null, selfAnd, selfAndNot, source, through, withoutDefaultScopes, } = opts;
39
39
  return function (_, context) {
40
40
  const key = context.name;
41
41
  context.addInitializer(function () {
@@ -57,21 +57,21 @@ export default function HasMany(globalAssociationNameOrNames, opts = {}) {
57
57
  dreamClass,
58
58
  dependent: dependent ?? null,
59
59
  methodName: key,
60
- on: on ?? null,
60
+ and: and ?? null,
61
61
  });
62
62
  const partialAssociation = associationPrimaryKeyAccessors({
63
63
  modelCB: () => lookupModelByGlobalNameOrNames(globalAssociationNameOrNames),
64
64
  as: key,
65
65
  dependent,
66
66
  globalAssociationNameOrNames,
67
- on,
68
- notOn,
69
- onAny,
67
+ and,
68
+ andNot,
69
+ andAny,
70
70
  polymorphic,
71
71
  preloadThroughColumns,
72
72
  primaryKeyOverride,
73
- selfOn,
74
- selfNotOn,
73
+ selfAnd,
74
+ selfAndNot,
75
75
  source: source || key,
76
76
  type: 'HasMany',
77
77
  withoutDefaultScopes,
@@ -20,20 +20,20 @@ import { applyGetterAndSetter, associationPrimaryKeyAccessors, blankAssociations
20
20
  *
21
21
  * @param opts.dependent - Can be either "destroy" or undefined. If "destroy", this record will be cascade deleted if the base model is destroyed.
22
22
  * @param opts.foreignKey - A custom column name to use for the foreign key.
23
- * @param opts.on - An on clause to be applied when this association is loaded
24
- * @param opts.notOn - A not on clause to be applied when this association is loaded
25
- * @param opts.onAny - An onAny clause to be applied when this association is loaded
23
+ * @param opts.and - An and-clause to be applied when this association is loaded
24
+ * @param opts.andNot - A not and-clause to be applied when this association is loaded
25
+ * @param opts.andAny - An andAny clause to be applied when this association is loaded
26
26
  * @param opts.polymorphic - If true, this association will be treated as a polymorphic association.
27
27
  * @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.
28
28
  * @param opts.primaryKeyOverride - A custom column name to use for the primary key.
29
- * @param opts.selfOn - Adds an on clause to an association between a column on the associated model and a column on this model.
30
- * @param opts.selfNotOn - Adds a not on clause to an association between a column on the associated model and a column on this model.
29
+ * @param opts.selfAnd - Adds an and-clause to an association between a column on the associated model and a column on this model.
30
+ * @param opts.selfAndNot - Adds a not and-clause to an association between a column on the associated model and a column on this model.
31
31
  * @param opts.source - Used in conjunction with 'through' to specify the source association on a child model.
32
32
  * @param opts.through - If passed, this association will travel through another association.
33
33
  * @param opts.withoutDefaultScopes - A list of default scopes to bypass when loading this association
34
34
  */
35
35
  export default function HasOne(globalAssociationNameOrNames, opts = {}) {
36
- const { dependent, foreignKey, on, notOn, onAny, polymorphic = false, preloadThroughColumns, primaryKeyOverride = null, selfOn, selfNotOn, source, through, withoutDefaultScopes, } = opts;
36
+ const { dependent, foreignKey, and, andNot, andAny, polymorphic = false, preloadThroughColumns, primaryKeyOverride = null, selfAnd, selfAndNot, source, through, withoutDefaultScopes, } = opts;
37
37
  return function (_, context) {
38
38
  const key = context.name;
39
39
  context.addInitializer(function () {
@@ -55,21 +55,21 @@ export default function HasOne(globalAssociationNameOrNames, opts = {}) {
55
55
  dreamClass,
56
56
  dependent: dependent ?? null,
57
57
  methodName: key,
58
- on: on ?? null,
58
+ and: and ?? null,
59
59
  });
60
60
  const partialAssociation = associationPrimaryKeyAccessors({
61
61
  modelCB: () => lookupModelByGlobalNameOrNames(globalAssociationNameOrNames),
62
62
  as: key,
63
63
  dependent,
64
64
  globalAssociationNameOrNames,
65
- on,
66
- notOn,
67
- onAny,
65
+ and,
66
+ andNot,
67
+ andAny,
68
68
  polymorphic,
69
69
  preloadThroughColumns,
70
70
  primaryKeyOverride,
71
- selfOn,
72
- selfNotOn,
71
+ selfAnd,
72
+ selfAndNot,
73
73
  source: source || key,
74
74
  through,
75
75
  type: 'HasOne',
@@ -3,7 +3,7 @@ import { DreamConst } from '../../../dream/constants.js';
3
3
  import { checkForeignKey } from '../../../errors/associations/InvalidComputedForeignKey.js';
4
4
  import NonLoadedAssociation from '../../../errors/associations/NonLoadedAssociation.js';
5
5
  import CannotDefineAssociationWithBothDependentAndPassthrough from '../../../errors/CannotDefineAssociationWithBothDependentAndPassthrough.js';
6
- import CannotDefineAssociationWithBothDependentAndRequiredOnClause from '../../../errors/CannotDefineAssociationWithBothDependentAndRequiredOnClause.js';
6
+ import CannotDefineAssociationWithBothDependentAndRequiredAndClause from '../../../errors/CannotDefineAssociationWithBothDependentAndRequiredAndClause.js';
7
7
  import camelize from '../../../helpers/camelize.js';
8
8
  import freezeBaseClassArrayMap from '../../helpers/freezeBaseClassArrayMap.js';
9
9
  import associationToGetterSetterProp from './associationToGetterSetterProp.js';
@@ -113,11 +113,11 @@ association: ${this.as}
113
113
  },
114
114
  };
115
115
  }
116
- export function validateHasStatementArgs({ dreamClass, dependent, methodName, on, }) {
117
- const hasPassthroughOn = Object.values(on || {}).find(val => val === DreamConst.passthrough);
118
- const hasRequiredOn = Object.values(on || {}).find(val => val === DreamConst.required);
119
- if (dependent && hasPassthroughOn)
116
+ export function validateHasStatementArgs({ dreamClass, dependent, methodName, and, }) {
117
+ const hasPassthroughAnd = Object.values(and || {}).find(val => val === DreamConst.passthrough);
118
+ const hasRequiredAnd = Object.values(and || {}).find(val => val === DreamConst.required);
119
+ if (dependent && hasPassthroughAnd)
120
120
  throw new CannotDefineAssociationWithBothDependentAndPassthrough(dreamClass, methodName);
121
- if (dependent && hasRequiredOn)
122
- throw new CannotDefineAssociationWithBothDependentAndRequiredOnClause(dreamClass, methodName);
121
+ if (dependent && hasRequiredAnd)
122
+ throw new CannotDefineAssociationWithBothDependentAndRequiredAndClause(dreamClass, methodName);
123
123
  }
@@ -311,11 +311,11 @@ export default class DreamInstanceTransactionBuilder {
311
311
  *
312
312
  * @returns A Query scoped to the specified association on the current instance
313
313
  */
314
- associationQuery(associationName, joinOnStatements) {
314
+ associationQuery(associationName, joinAndStatements) {
315
315
  if (this.dreamInstance.isNewRecord)
316
316
  throw new CannotAssociationQueryOnUnpersistedDream(this.dreamInstance, associationName);
317
317
  return associationQuery(this.dreamInstance, this.dreamTransaction, associationName, {
318
- joinOnStatements: joinOnStatements,
318
+ joinAndStatements: joinAndStatements,
319
319
  bypassAllDefaultScopes: DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
320
320
  defaultScopesToBypass: DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
321
321
  });
@@ -330,7 +330,7 @@ export default class DreamInstanceTransactionBuilder {
330
330
  * await ApplicationModel.transaction(async txn => {
331
331
  * await user.txn(txn).createAssociation('posts', { body: 'hello world' })
332
332
  * await user.txn(txn).createAssociation('posts', { body: 'howyadoin' })
333
- * await user.txn(txn).updateAssociation('posts', { body: 'goodbye world' }, { on: { body: 'hello world' }})
333
+ * await user.txn(txn).updateAssociation('posts', { body: 'goodbye world' }, { and: { body: 'hello world' }})
334
334
  * // 1
335
335
  * })
336
336
  * ```
@@ -348,10 +348,10 @@ export default class DreamInstanceTransactionBuilder {
348
348
  if (this.dreamInstance.isNewRecord)
349
349
  throw new CannotUpdateAssociationOnUnpersistedDream(this.dreamInstance, associationName);
350
350
  return await associationUpdateQuery(this.dreamInstance, this.dreamTransaction, associationName, {
351
- joinOnStatements: {
352
- on: updateAssociationOptions?.on,
353
- notOn: updateAssociationOptions?.notOn,
354
- onAny: updateAssociationOptions?.onAny,
351
+ joinAndStatements: {
352
+ and: updateAssociationOptions?.and,
353
+ andNot: updateAssociationOptions?.andNot,
354
+ andAny: updateAssociationOptions?.andAny,
355
355
  },
356
356
  bypassAllDefaultScopes: updateAssociationOptions?.bypassAllDefaultScopes ?? DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
357
357
  defaultScopesToBypass: updateAssociationOptions?.defaultScopesToBypass ?? DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
@@ -383,13 +383,15 @@ export default class DreamInstanceTransactionBuilder {
383
383
  *
384
384
  * ```ts
385
385
  * await ApplicationModel.transaction(async txn => {
386
- * await user.txn(txn).destroyAssociation('posts', { on: { body: 'hello world' } })
386
+ * await user.txn(txn).destroyAssociation('posts', { and: { body: 'hello world' } })
387
387
  * })
388
388
  * ```
389
389
  *
390
390
  * @param associationName - The name of the association to destroy
391
391
  * @param options - Options for destroying the association
392
- * @param options.on - Optional where statement to apply to query before destroying
392
+ * @param options.and - Optional and statement to apply to query before destroying
393
+ * @param options.andNot - Optional andNot statement to apply to query before destroying
394
+ * @param options.andAny - Optional andAny statement to apply to query before destroying
393
395
  * @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
394
396
  * @param options.cascade - If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true
395
397
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
@@ -401,10 +403,10 @@ export default class DreamInstanceTransactionBuilder {
401
403
  throw new CannotDestroyAssociationOnUnpersistedDream(this.dreamInstance, associationName);
402
404
  return await destroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
403
405
  ...destroyOptions(options),
404
- joinOnStatements: {
405
- on: options?.on,
406
- notOn: options?.notOn,
407
- onAny: options?.onAny,
406
+ joinAndStatements: {
407
+ and: options?.and,
408
+ andNot: options?.andNot,
409
+ andAny: options?.andAny,
408
410
  },
409
411
  });
410
412
  }
@@ -419,13 +421,15 @@ export default class DreamInstanceTransactionBuilder {
419
421
  *
420
422
  * ```ts
421
423
  * await ApplicationModel.transaction(async txn => {
422
- * await user.txn(txn).reallyDestroyAssociation('posts', { on: { body: 'hello world' } })
424
+ * await user.txn(txn).reallyDestroyAssociation('posts', { and: { body: 'hello world' } })
423
425
  * })
424
426
  * ```
425
427
  *
426
428
  * @param associationName - The name of the association to destroy
427
429
  * @param options - Options for destroying the association
428
- * @param options.on - Optional where statement to apply to query before destroying
430
+ * @param options.and - Optional and statement to apply to query before destroying
431
+ * @param options.andNot - Optional andNot statement to apply to query before destroying
432
+ * @param options.andAny - Optional andAny statement to apply to query before destroying
429
433
  * @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
430
434
  * @param options.cascade - If true, cascades the destroy operation to associations marked with `dependent: 'destroy'`. Defaults to true
431
435
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
@@ -437,10 +441,10 @@ export default class DreamInstanceTransactionBuilder {
437
441
  throw new CannotDestroyAssociationOnUnpersistedDream(this.dreamInstance, associationName);
438
442
  return await destroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
439
443
  ...reallyDestroyOptions(options),
440
- joinOnStatements: {
441
- on: options?.on,
442
- notOn: options?.notOn,
443
- onAny: options?.onAny,
444
+ joinAndStatements: {
445
+ and: options?.and,
446
+ andNot: options?.andNot,
447
+ andAny: options?.andAny,
444
448
  },
445
449
  });
446
450
  }
@@ -451,12 +455,14 @@ export default class DreamInstanceTransactionBuilder {
451
455
  * will also be undeleted.
452
456
  *
453
457
  * ```ts
454
- * await user.undestroyAssociation('posts', { on: { body: 'hello world' } })
458
+ * await user.undestroyAssociation('posts', { and: { body: 'hello world' } })
455
459
  * ```
456
460
  *
457
461
  * @param associationName - The name of the association to undestroy
458
462
  * @param options - Options for undestroying the association
459
- * @param options.on - Optional where statement to apply to query before undestroying
463
+ * @param options.and - Optional and statement to apply to query before undestroying
464
+ * @param options.andNot - Optional andNot statement to apply to query before undestroying
465
+ * @param options.andAny - Optional andAny statement to apply to query before undestroying
460
466
  * @param options.skipHooks - If true, skips applying model hooks during the undestroy operation. Defaults to false
461
467
  * @param options.cascade - If false, skips undestroying associations marked `dependent: 'destroy'`. Defaults to true
462
468
  * @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when undestroying the association. Defaults to false
@@ -466,10 +472,10 @@ export default class DreamInstanceTransactionBuilder {
466
472
  async undestroyAssociation(associationName, options) {
467
473
  return await undestroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
468
474
  ...undestroyOptions(options),
469
- joinOnStatements: {
470
- on: options?.on,
471
- notOn: options?.notOn,
472
- onAny: options?.onAny,
475
+ joinAndStatements: {
476
+ and: options?.and,
477
+ andNot: options?.andNot,
478
+ andAny: options?.andAny,
473
479
  },
474
480
  });
475
481
  }