Class Promise

View code A slightly modified version of bluebird promises. This means that, on top of the methods below, you can also call all the methods listed on the link below.

The main difference is that sequelize promises allows you to attach a listener that will be called with the generated SQL, each time a query is run.

The sequelize promise class works seamlessly with other A+/thenable libraries, with one exception. If you want to propagate SQL events across then, all calls etc., you must use sequelize promises exclusively.

Mixes:

  • https://github.com/petkaantonov/bluebird/blob/master/API.md

on(evt, fct)

View code Listen for events, event emitter style. Mostly for backwards compat. with EventEmitter

Deprecated

Params:

Name Type Description
evt String
fct Function

emit(type, value(s)*)

View code Emit an event from the emitter Deprecated

Params:

Name Type Description
type string The type of event
value(s)* any All other arguments will be passed to the event listeners

success(onSuccess) -> this

View code Listen for success events.

promise.success(function (result) {
 //...
});

Deprecated

Params:

Name Type Description
onSuccess function

Aliases: ok


error(onError) -> this

View code Listen for error events

promise.error(function (err) {
 //...
});

Deprecated

Params:

Name Type Description
onError function

Aliases: fail, failure


done(onDone) -> this

View code Listen for both success and error events.

promise.done(function (err, result) {
 //...
});

Deprecated done(fct) is deprecated, done() is regular promise syntax to explicitly signal the end of a promise chain and will not be deprecated

Params:

Name Type Description
onDone function

Aliases: complete


sql(onSQL) -> this

View code Attach a function that is called every time the function that created this emitter executes a query.

Params:

Name Type Description
onSQL function

proxy(promise, [options]) -> this

View code Proxy every event of this promise to another one.

Deprecated

Params:

Name Type Description
promise SequelizePromise The promise that should receive the events.
[options] Object
[options.events] Array An array of the events to proxy. Defaults to sql, error and success

This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on IRC, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see JSDoc and dox