Skip to content
Brian edited this page May 15, 2016 · 1 revision
 dropTrigger(triggerName[, options])

JSQL query used to delete a trigger from the database. A trigger watches a specific table for insert queries, delete queries, or update queries (possibly for only specific fields in an update query). When the appropriate query occurs, the trigger will fire one or more callback functions before the query is processed, after the query is processed, or instead of processing the query. "Instead" triggers can alter the normal return value of the query.

Table of Contents

Parameters

triggerName

The name of the trigger to drop. dropTrigger will throw an error if triggerName is an empty string or ends with a period.

If the name contains a space, everything after the last space will be ignored.

If the name contains a period, everything before the last period (which is also before the last space) will be used to choose the schema to find the trigger in. If the name does not contain a period, the default schema will be used.

options (optional)

See options for additional information.

Options for modifying the behavior of the dropTable query.

Property Default Explanation
dropTriggerIfExists true If the named trigger doesn't exist and this option is false, the query will throw an error.
ifExists Alias for dropTriggerIfExists
useTransaction null If set to a Transaction object, executing the query will add the query to the transaction's queue instead of actually executing it.

Returns

The dropTrigger function returns a DropTrigger object, which is a subclass of cls.QueryBuilder. However, there is nothing to the building of a dropTrigger query beyond the trigger name, so only one function is available:

execute([options])

Performs the trigger deletion operation.

options.dropTriggerIfExists (alias ifExists) and options.useTransaction can override the same options specified in dropTrigger and cls.DefaultOptions.

This function will return true if the trigger is dropped successfully. If options.dropTriggerIfExists is true and the trigger doesn't exist, this function will return false and take no action. If options.dropTriggerIfExists is false and the trigger doesn't exist, this function will throw an error.

Clone this wiki locally