Model Object
Model Object
addError()— Adds a custom error to a model instance. This is useful when built-in validations don’t fully cover your business rules,addErrorToBase()— Adds an error directly on the model object itself, not tied to a specific property. This is useful when the error applieallChanges()— Returns a struct containing all unsaved changes made to an object since it was last loaded or saved. Each entry in the sallErrors()— Returns an array of all the errors on the object.changedFrom()— Returns the previous value of a property that has been modified on a model object. Wheels tracks changes to object propechangedProperties()— Returns a list of property names that have been modified on a model object but not yet saved to the database. This is usclearChangeInformation()— Clears all internal tracking information that Wheels maintains about an object’s properties. This does not undo changesclearErrors()— Clears all validation or manual errors stored on a model object. You can clear all errors, or target specific errors eitcompareTo()— Compares the current model object with another model object to determine if they are effectively the same. This is usefudelete()— Deletes the object, which means the row is deleted from the database (unless prevented by abeforeDeletecaerrorCount()— Returns the number of errors this object has associated with it.errorsOn()— errorsOn() returns an array of all errors associated with a specific property of a model object. You can also filter byerrorsOnBase()— errorsOnBase() returns an array of all errors associated with the object as a whole, not tied to any specific property.hasChanged()— Returnstrueif the specified property (or any if none was passed in) has been changed but not yet saved tohasErrors()— Checks whether a model object has any validation or other errors. It returns true if the object contains errors, or if ahasProperty()— Checks if a given property exists on a model object. It’s useful for safely validating whether a field is defined beforeisNew()— Returnstrueif this object hasn’t been saved yet (in other words, no matching record exists in the databasisPersisted()— Returnstrueif this object has been persisted to the database or was loaded from the database via a finderkey()— Returns the value of the primary key for the object.properties()— Returns a structure containing all the properties of a model object, where the keys are the property (column) names andpropertyIsBlank()— Returnstrueif the specified property doesn’t exist on the model or is an empty string.propertyIsPresent()— Returnstrueif the specified property exists on the model and is not a blank string. This is the inverse oreload()— Refreshes the property values of a model object from the database. This is useful when an object’s values might have chasetProperties()— Allows you to set multiple properties of a model object at once. It is useful when you want to update a model with a strtoggle()— Assigns to the property specified the opposite of the property’s current boolean value.update()— Updates an existing model object with the supplied properties and saves the changes to the database. It returns true ifupdateProperty()— Updates a single property on a model object and saves the record immediately without running the normal validation procevalid()— Runs the validation on the object and returnstrueif it passes it.