You are viewing documentation for v1.0.x. Change

afterFind()

Description

Registers method(s) that should be called after an existing object has been initialized (usually done with the findByKey() or findOne() method).

Function Syntax

afterFind([ methods ])

Parameters

Parameter Type Required Default Description
methods string No Method name or list of method names that should be called when this callback event occurs in an object's life cycle (can also be called with the method argument).

Examples

<!--- Instruct Wheels to call the `setTime` method after getting objects or records with one of the finder methods --->
<cffunction name="init">
    <cfset afterFind("setTime")>
</cffunction>

<cffunction name="setTime">
    <cfif StructIsEmpty(arguments)>
<cfset this.fetchedAt = Now()>
    <cfelse>
<cfset arguments.fetchedAt = Now()>
<cfreturn arguments>
    </cfif>
</cffunction>