编辑:
INPUT:节点DB
if (Meteor.isServer) {
var nodeDB = new Meteor.Collection('nodes');
Meteor.startup(function () {
// code to run on server at startup
});
var p1=nodeDB.find({"ACTIVE" : 1, "VARIENTS.ACCESS" : "PUBLIC"}, { "VARIENTS.NAME": 1, _id : 0 });
var p2=p1.fetch();
var arr1=[];
var arr2=[];
for (i=0;i <p2.length;i++)
{
//console.log(p2[i].VARIENTS);
arr1[i]=p2[i].VARIENTS;
}
var dict=(arr1[1]);
// console.log(x.length);
console.log(arr1.NAME);
Meteor.startup(function () {
// code to run on server at startup
});
}
输入:
[ [ { COMMENT: 'Demo',
I20150521-15:50:47.855(5.5)? INDEX: 0,
I20150521-15:50:47.856(5.5)? NAME: 'Brand',
I20150521-15:50:47.856(5.5)? IS_PARENT: false,
I20150521-15:50:47.856(5.5)? DATATYPE: 'Text',
I20150521-15:50:47.856(5.5)? ACCESS: 'PUBLIC',
I20150521-15:50:47.856(5.5)? PARENT_VARIENT: 'Parem',
I20150521-15:50:47.856(5.5)? TYPE: 'PERMANENT' },
I20150521-15:50:47.856(5.5)? { COMMENT: 'Demo',
I20150521-15:50:47.857(5.5)? INDEX: 0,
I20150521-15:50:47.857(5.5)? NAME: 'Account',
I20150521-15:50:47.857(5.5)? IS_PARENT: false,
I20150521-15:50:47.857(5.5)? DATATYPE: 'Text',
I20150521-15:50:47.857(5.5)? ACCESS: 'PUBLIC',
I20150521-15:50:47.857(5.5)? PARENT_VARIENT: 'Parem',
I20150521-15:50:47.857(5.5)? TYPE: 'PERMANENT' },
I20150521-15:50:47.857(5.5)? { COMMENT: 'Demo',
I20150521-15:50:47.858(5.5)? INDEX: 0,
I20150521-15:50:47.858(5.5)? NAME: 'Price',
I20150521-15:50:47.858(5.5)? IS_PARENT: false,
I20150521-15:50:47.858(5.5)? DATATYPE: 'Text',
I20150521-15:50:47.858(5.5)? ACCESS: 'PUBLIC',
I20150521-15:50:47.858(5.5)? PARENT_VARIENT: 'Parem',
I20150521-15:50:47.859(5.5)? TYPE: 'PERMANENT' } ] ]
结果:
{{1}}
问题:所需的结果只是数组中的NAME参数。如何修改查询?
答案 0 :(得分:1)
Mongo查询: -
{
"result" : [
{
"TEMPLATE_NAME" : [
"Brand",
"Account",
"Price"
]
}
],
"ok" : 1
}
Mongo结果: -
for key, value in prices.items():
print(key)