Closed kosmikko closed 9 years ago
Looks good apart from the comment above. Somewhat coincidentally, I've been thinking of how to make the interplay between fetch and use less implicit and fragile. There seems to be a proliferation of 'fetchXXXDependencies' methods, and subsequent operations on the model may fail if you've fetched it the wrong way.
So I think there might be use for a public async method to fetch a relation on demand:
model.fetchRelation('admirers').then(function (admirers) {
// ...
});
Then, for example, the ACL check would, in most general form, be an async operation done in preFetch
/preSave
/preDelete
(the current .canAccess
and .getRoles
could be retained for the simple default implementation), and there won't be need for fetchACLDependencies
. Same for other code that currently relies on internal properties populated by fetchAll
and the like.
This PR fixes #18.