deleteData()

Overview

public numeric function deleteData(
      required string  objectName    
    ,          string  id            
    ,          any     filter        
    ,          struct  filterParams  
    ,          array   extraFilters  
    ,          array   savedFilters  
    ,          boolean forceDeleteAll = false
)

Deletes records from the database. Returns the number of records deleted.

Arguments

NameTypeRequiredDescription
objectNamestringYesName of the object from whose database table records are to be deleted
idstringNoID of a record to delete
filteranyNoFilter for records to delete, see :ref:`preside-objects-filtering-data` in :doc:`/devguides/presideobjects`
filterParamsstructNoFilter params for plain SQL filter, see :ref:`preside-objects-filtering-data` in :doc:`/devguides/presideobjects`
extraFiltersarrayNoAn array of extra sets of filters. Each array should contain a structure with :code:`filter` and optional `code:`filterParams` keys.
savedFiltersarrayNo
forceDeleteAllbooleanNo (default=false)If no id or filter supplied, this must be set to **true** in order for the delete to process

Examples

// delete a single record
deleted = presideObjectService.deleteData(
          objectName = "event"
        , id         = rc.id
);


// delete multiple records using a filter
// (note we are filtering on a column in a related object, "category")
deleted = presideObjectService.deleteData(
          objectName   = "event"
        , filter       = "category.label != :category.label"
        , filterParams = { "category.label" = "BBQs" }
);


// delete all records
// (note we are filtering on a column in a related object, "category")
deleted = presideObjectService.deleteData(
          objectName     = "event"
        , forceDeleteAll = true
);