Allow include syntax without scope param
This commit is contained in:
parent
771d9505cc
commit
8d6e3adaab
|
@ -15,7 +15,7 @@ function normalizeInclude(include) {
|
|||
// Build an array of key/value pairs
|
||||
var newInclude = [];
|
||||
var rel = include.rel || include.relation;
|
||||
if (typeof rel === 'string' && isPlainObject(include.scope)) {
|
||||
if (typeof rel === 'string') {
|
||||
var obj = {};
|
||||
obj[rel] = new IncludeScope(include.scope);
|
||||
newInclude.push(obj);
|
||||
|
|
|
@ -79,6 +79,17 @@ describe('include', function () {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should fetch Passport - Owner - Posts - alternate syntax', function (done) {
|
||||
Passport.find({include: {owner: {relation: 'posts'}}}, function (err, passports) {
|
||||
should.not.exist(err);
|
||||
should.exist(passports);
|
||||
passports.length.should.be.ok;
|
||||
var posts = passports[0].owner().posts();
|
||||
posts.should.have.length(3);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should fetch Passports - User - Posts - User', function (done) {
|
||||
Passport.find({
|
||||
|
|
Loading…
Reference in New Issue