Model Object
clearChangeInformation()
Signature
Section titled “Signature”clearChangeInformation() — returns void
Available in: model
Category: Change Functions
Description
Section titled “Description”Clears all internal knowledge of the current state of the object, including what the last save
changed (savedChanges()).
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
property | string | no | — | string false Name of property to clear information for. |
Examples
Section titled “Examples”// 1. Clear change tracking for a single property
// Convert startTime to UTC in an afterFind callback, then tell Wheels to treat
// the converted value as the "original" so it won't be flagged as changed or
// saved unnecessarily.
this.startTime = dateConvert("Local2UTC", this.startTime);
this.clearChangeInformation(property="startTime");
// 2. Clear change tracking for all properties at once
// After manually adjusting values in an afterFind callback, reset Wheels'
// internal state so none of the touched properties appear as dirty.
this.clearChangeInformation();
// 3. Typical afterFind callback usage in a model
// In User.cfc config():
// afterFind("normalizeTimestamps");
// The callback method:
function normalizeTimestamps() {
if (structKeyExists(this, "createdAt")) {
this.createdAt = dateConvert("Local2UTC", this.createdAt);
}
if (structKeyExists(this, "updatedAt")) {
this.updatedAt = dateConvert("Local2UTC", this.updatedAt);
}
// Mark both properties as clean so hasChanged() returns false
// and save() won't push them back to the database.
this.clearChangeInformation(property="createdAt");
this.clearChangeInformation(property="updatedAt");
}