Deleting a record is also quite simple. As with the load() method, Reactor defaults to using the primary key values for the record you're deleting.
You must first create a Record object:
<!--- create the reactorFactory --->
<cfset reactor = CreateObject("Component", "reactor.reactorFactory").init(expandPath("reactor.xml"))
/>
<!--- create a userRecord --->
<cfset UserRecord = reactor.createRecord("User") />
Now that you have the Record you can set its primary key value(s):
<!--- set the record to delete --->
<cfset UserRecord.setUserId(2) />
In many cases you may actually have already loaded the object by this point. It's not strictly necessary, but it works just fine. You can delete a record which has never been loaded. This code shows how:
<!--- delete the record --->
<cfset UserRecord.delete() />
If you run this code, the record we created earlier would be deleted from the database. If, for whatever reason, the Record object had been loaded previous to calling the delete() method, it would have worked just fine.
The same code can be written in shorthand like this:
<!--- load the record --->
<cfset UserRecord = Reactor.createRecord("User").delete(userId=2)
/>