function (query, next) {
        switch (ctx.type) {
          case 'model':
            Model.find(query, next);
            break;
          case 'relation':
            Model.findOne(query, function (err, instance) {
              if (err) return next(err);
              var builder = new _queryBuilder2.default({
                type: ctx.type,
                count: ctx.count,
                now: ctx.now,
                nowISOString: ctx.nowISOString,
                params: {
                  range: ctx.params.range,
                  where: ctx.params.where,
                  custom: ctx.params.custom
                }
              });
              builder.onComplete(function (_err, _query) {
                if (_err) return next(_err);
                instance[ctx.relation || ctx.params.relation](_query, next);
              });
              builder.build();
            });
            break;
          case 'nested':
            Model.findOne(query, function (err, instance) {
              return next(err, instance[ctx.nested]);
            });
            break;
          default:
            next(null, []);
        }
      }
function (query, next) {
        switch (ctx.type) {
          case 'model':
            Model.find(query, next);
            break;
          case 'relation':
            Model.findOne(query, function (err, instance) {
              if (err) return next(err);
              var builder = new _queryBuilder2.default({
                type: ctx.type,
                count: ctx.count,
                now: ctx.now,
                nowISOString: ctx.nowISOString,
                params: {
                  range: ctx.params.range,
                  where: ctx.params.where,
                  custom: ctx.params.custom
                }
              });
              builder.onComplete(function (_err, _query) {
                if (_err) return next(_err);
                instance[ctx.relation || ctx.params.relation](_query, next);
              });
              builder.build();
            });
            break;
          case 'nested':
            Model.findOne(query, function (err, instance) {
              return next(err, instance[ctx.nested]);
            });
            break;
          default:
            next(null, []);
        }
      }
function ( query , next ) { switch ( ctx . type ) { case 'model' : Model . find ( query , next ) ; break ; case 'relation' : Model . findOne ( query , function ( err , instance ) { if ( err ) return next ( err ) ; var builder = new _queryBuilder2 . default ( { type : ctx . type , count : ctx . count , now : ctx . now , nowISOString : ctx . nowISOString , params : { range : ctx . params . range , where : ctx . params . where , custom : ctx . params . custom } } ) ; builder . onComplete ( function ( _err , _query ) { if ( _err ) return next ( _err ) ; instance [ ctx . relation || ctx . params . relation ] ( _query , next ) ; } ) ; builder . build ( ) ; } ) ; break ; case 'nested' : Model . findOne ( query , function ( err , instance ) { return next ( err , instance [ ctx . nested ] ) ; } ) ; break ; default : next ( null , [ ] ) ; } }
Get List of Items
Get List of Items