velocious 1.0.507 → 1.0.508

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.
@@ -46,7 +46,7 @@ import singularizeModelName from "../../utils/singularize-model-name.js"
46
46
  import {defineModelScope} from "../../utils/model-scope.js"
47
47
  import { normalizeDateStringForWrite, normalizeDateValueForRead, normalizeDateValueForWrite } from "../datetime-storage.js"
48
48
  import {formatValue} from "../../utils/format-value.js"
49
- import {captureCreateAuditChanges, captureUpdateAuditChanges, createAudit, createCreateAudit, createDestroyAudit, createUpdateAudit, registerAuditCallback, registerAuditing, withoutAudit} from "./auditing.js"
49
+ import {captureCreateAuditChanges, captureUpdateAuditChanges, createAudit, createCreateAudit, createDestroyAudit, createUpdateAudit, initializeAuditing, registerAuditCallback, registerAuditing, withoutAudit} from "./auditing.js"
50
50
  import {registerMagnitudeCounterCache} from "./counter-cache-magnitude.js"
51
51
  import {stateMachine} from "./state-machine.js"
52
52
  import ValidatorsFormat from "./validators/format.js"
@@ -1533,6 +1533,7 @@ class VelociousDatabaseRecord {
1533
1533
  }
1534
1534
 
1535
1535
  await this._defineTranslationMethods()
1536
+ await initializeAuditing(this)
1536
1537
  this._initialized = true
1537
1538
  }
1538
1539
 
@@ -218,6 +218,12 @@ export default class VelociousDatabaseRecordHasManyInstanceRelationship extends
218
218
 
219
219
  whereArgs[foreignKey] = primaryModelID
220
220
 
221
+ if (this.getRelationship().getPolymorphic()) {
222
+ const typeColumn = this.getRelationship().getPolymorphicTypeColumn()
223
+
224
+ whereArgs[typeColumn] = this.getModel().getModelClass().getModelName()
225
+ }
226
+
221
227
  const query = TargetModelClass.where(whereArgs)
222
228
 
223
229
  return this.applyScope(query)