来自findById操作的混淆对象

时间:2015-05-29 15:52:56

标签: node.js strongloop loopback

我不知道这是我的javascript语法错误还是只是错误地使用了loopback。 当我从模型执行过滤器并打印(公司对象)

Company.findById(companyId, {
  include: 'markers'
}, function(err, company) {
 console.log(company);
});

控制台向我显示此输出(它很好)

{ id: '85',
name: 'myName',
ruc: '45453453232',
logo: 'https://res.cloudinary.com/dphutkz4b/image/',
location: 'Bolivia',
imageAd: 'http://res.cloudinary.com/dphutkz4b/image/upload/',
markers:
 [ { id: '104',
     valueLk: 666,
     position: '-12.101419,-77.033414',
     city: 'Glasgow',
     district: 'Ate',
     banner: 'http://res.cloudinary.com/dphutkz4b/image/',
     companyId: '85' } ] }

但是当我从对象而不是console.log(公司)打印属性标记时,

console.log(company.markers);

输出是一个完整的函数,当我想在.jade文件中使用时会出现问题

function (condOrRefresh, cb) {
    if (arguments.length === 0) {
      if (typeof f.value === 'function') {
        return f.value(self);
      } else if (self.__cachedRelations) {
        return self.__cachedRelations[name];
      }
    } else {
      // Check if there is a through model
      // see https://github.com/strongloop/loopback/issues/1076
      if (f._scope.collect &&
        condOrRefresh !== null && typeof condOrRefresh === 'object') {
        // Adjust the include so that the condition will be applied to
        // the target model
        f._scope.include = {
          relation: f._scope.collect,
          scope: condOrRefresh
        };
        condOrRefresh = {};
      }
      if (arguments.length === 1) {
        return definition.related(self, f._scope, condOrRefresh);
      } else {
        return definition.related(self, f._scope, condOrRefresh, cb);
      }
    }
  }

0 个答案:

没有答案