【发布时间】:2018-05-19 00:56:02
【问题描述】:
我有一个运行良好的 Google Cloud 函数,我希望在回调之前执行一次后,连接到 Firestore 以将文档添加到我的 Notifications 集合中。
const Firestore = require('@google-cloud/firestore');
const firestore = new Firestore({
projectId: 'my-firebase-project',
keyFilename: 'thekey.json',
});
var fsDocument = {
'username': 'theuser',
'organization': 'theorg',
'attr': [
{k:'key1', v:'val1'},
{k:'key2', v:'val2'}
]
};
firestore.collection('Notifications').add(fsDocument).then(documentReference => {
console.log('Added document with name' + documentReference.id);
});
如何将密钥文件包含到我的谷歌云功能中?到目前为止,我正在 console.cloud.google.com 中创建它们。
【问题讨论】:
标签: node.js firebase google-cloud-platform google-cloud-functions google-cloud-firestore