2

これが私の JavaScript 構文エラーなのか、単にループバックの使い方が悪いのかはわかりません。モデルからフィルターを実行して印刷する場合 (会社オブジェクト)

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(company); の代わりにオブジェクトからプロパティ マーカーを出力すると、

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);
      }
    }
  }
4

0 に答える 0