【发布时间】:2018-12-06 07:49:52
【问题描述】:
我正在使用以下代码从 Cloud Firestore 获得价值
dbManager = admin.initializeApp(functions.config().firebase);
this.dbManager.collection("test").doc("myTest").get().then( async test=> {
console.log("test---------------->",test);
console.log("test---------------->",test._fieldsProto['tests']);
console.log("test---data------------->",test.data()['tests'].values);
});
而我使用test.data()['tests']时得到的值是
{ values:
[ { mapValue: [Object], valueType: 'mapValue' },
{ mapValue: [Object], valueType: 'mapValue' },
{ mapValue: [Object], valueType: 'mapValue' },
{ mapValue: [Object], valueType: 'mapValue' },
{ mapValue: [Object], valueType: 'mapValue' },
{ mapValue: [Object], valueType: 'mapValue' },
{ mapValue: [Object], valueType: 'mapValue' },
{ mapValue: [Object], valueType: 'mapValue' },
{ mapValue: [Object], valueType: 'mapValue' } ] }
如何从中获取值?当我尝试使用 test.data()['tests'].array.forEach 之类的 foreach 时,它不起作用。
【问题讨论】:
-
我无法弄清楚您的实际文档是什么样的。您能否发布
myTest文档的屏幕截图,如Firebase Database console 中所示? -
以什么方式“不工作”?你得到错误的输出,或者根本没有,或者一个错误?
标签: node.js typescript firebase google-cloud-firestore