From 8d6e3adaabd13e2a65449cd003312ca256cd4072 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Fri, 10 Oct 2014 17:17:36 +0200 Subject: [PATCH] Allow include syntax without scope param --- lib/include.js | 2 +- test/include.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/include.js b/lib/include.js index 3afa1c02..eddf7a39 100644 --- a/lib/include.js +++ b/lib/include.js @@ -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); diff --git a/test/include.test.js b/test/include.test.js index 9021a724..1773eb2b 100644 --- a/test/include.test.js +++ b/test/include.test.js @@ -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({