我不知道这是我的 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);
}
}
}