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

deleteOne()

Description

Gets an object based on conditions and deletes it.

Function Syntax

deleteOne([ where, order ])

Parameters

Parameter Type Required Default Description
where string No This argument maps to the WHERE clause of the query. The following operators are supported: =, <>, <, <=, >, >=, LIKE, AND, and OR (note that the key words have to be written in upper case). You can also use parentheses to group statements. You do not have to specify the table name(s), Wheels will do that for you.
order string No This argument maps to the ORDER BY clause of the query. You do not have to specify the table name(s), Wheels will do that for you.

Examples

<!--- Delete the user that signed up last --->
<cfset result = model("user").deleteOne(order="signupDate DESC")>

<!--- If you have a `hasOne` association setup from `user` to `profile` you can do a scoped call (the `deleteProfile` method below will call `model("profile").deleteOne(where="userId=#aUser.id#")` internally) --->
<cfset aUser = model("user").findByKey(params.userId)>
<cfset aUser.deleteProfile()>