【发布时间】:2020-02-23 00:12:29
【问题描述】:
我正在尝试将一些示例数据播种到我的本地 Firestore 模拟器数据库中。我改编了this github issue的示例
我的代码如下所示:
const {Firestore} = require('@google-cloud/firestore');
const {credentials} = require('grpc');
const db = new Firestore({
projectId: 'my-project-id',
servicePath: 'localhost',
port: 8100,
sslCreds: credentials.createInsecure(),
customHeaders: {
"Authorization": "Bearer owner"
}
});
async function load_data() {
await db.collection("mycollection").doc("myid").set({ foo: "test" })
}
load_data();
但我收到错误提示
this.credentials._getCallCredentials 不是函数
在节点 10 和 12 上测试,错误相同。
库版本:
- @google-cloud/firestore 3.5.1
- grpc 1.24.2
是否有更好的方法来写入本地模拟 Firestore?还是我的代码有问题?
【问题讨论】:
标签: node.js firebase google-cloud-firestore grpc