Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When a callback is omitted from a method on a model relation that supports promises, return that promise. This includes all the standard DAO methods, as well as any user-defined methods that return promises. e.g.: mylist.todos.create({name: 'Item 1'}) // returns Promise This API will use native ES6 promises if available. If not available, or to force the use of another Promise library, you must assign the global.Promise object. e.g.: global.Promise = require('bluebird') Relations affected: - BelongsTo - HasOne - HasMany - HasManyThrough - HasAndBelongsToMany - ReferencesMany - EmbedsOne Exceptions: The EmbedsMany relation has not been promisified, because most of the methods return synchronous values. The base relation getter method [e.g.: mylist.todos()] has not been promisified, due to its default caching behavior. New Methods: - getAsync(condition, cb) A new method "getAsync()" has been added to all relations except EmbedsMany, which always fetches from the datasource rather than from the cache. It takes an optional "where" condition (except for HasOne and BelongsTo) and an optional callback. If the callback is omitted, a Promise is returned.
- Loading branch information