2

I don't know if this is my javascript syntax error or just a bad use of loopback. When I execute a filter from a model and print (company object)

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

The console shows me this output (it's good)

{ 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' } ] }

But when I print the property markers from the object instead of the console.log(company);

console.log(company.markers);

The output is a whole function and this cause a problem when I want to use in a .jade file

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);
      }
    }
  }
laggingreflex
  • 32,948
  • 35
  • 141
  • 196

0 Answers0