0
我有以下JSON对象,这是loopback
模型(分类)的结果,与另一个模型(标签)的关系。访问包含的对象
我的调用来获取分类为:
modClassification.findOne({
where: { id: classificationid },
include: 'labels' },
function(err, classification){ ...
而这个返回分类的东西,如
{ id: 'b01',
title: 'population',
country_id: 1,
labels:
[ { column_id: 'b1',
classification_id: 'b01',
classification_title: 'population',
dsporder: 1,
label: 'Total_Persons_Males',
country_id: 1,
id: 1 },
{ column_id: 'b2',
classification_id: 'b01',
classification_title: 'population',
dsporder: 2,
label: 'Total_Persons_Females',
country_id: 1,
id: 2 } ] }
这正是我所期望的。
我现在需要遍历标签并访问它的属性,但这是我卡住的地方。
classification.labels[0] = undefined..
我试过循环,每一个,无论我可以在网上找到,但似乎无法得到每个标签的属性。
有人能告诉我我做错了什么/需要做什么?
感谢
正是我失踪的!感谢Brian! – Jason