我正在尝试从查询中检索文档引用.我的代码返回undefined.我可以通过提取各个部分来获得路径documentSnapshot.ref,但这不是直截了当的.
我想要返回的是一个参考,然后我可以将.update其用于文档,而无需指定集合和使用documentSnapshot.id
该path物业的文件在这里
const db = admin.firestore();
return db.collection('myCollection').get().then(querySnapshot => {
querySnapshot.forEach(documentSnapshot => {
console.log(`documentReference.id = ${documentSnapshot.id}`);
console.log(`documentReference.path = ${documentSnapshot.path}`);
// console.log(`documentReference.ref = ${JSON.stringify(documentSnapshot.ref)}`);
});
});
Run Code Online (Sandbox Code Playgroud)
documentReference.id = Jez7R1GAHiR9nbjS3CQ6
documentReference.path = undefined
documentReference.id = skMmxxUIFXPyVa7Ic7Yp
documentReference.path = undefined
Run Code Online (Sandbox Code Playgroud) 当我尝试使用环境变量对Cloud Firestore进行身份验证时,我收到ENAMETOOLONG错误.我搜索了很多地方的文档.如果有人能指出我正确的方向,这将是有用的.
我已经创建了一个环境变量来加载我的服务帐户密钥
export MY_CREDENTIALS=$(cat myGoogleServiceAccountKey.json)
const admin = require('firebase-admin');
var serviceAccount = process.env.MY_CREDENTIALS;
// console.log(`Service account = ${serviceAccount}`);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
const db = admin.firestore();
Run Code Online (Sandbox Code Playgroud)
当我运行从我的环境变量中获取serviceaccount键的节点脚本时,我收到以下错误:
/home/jason/Downloads/projects/myProject/functions/node_modules/firebase-admin/lib/auth/credential.js:142
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse certificate key file: ' + error);
^
Error: Failed to parse certificate key file: Error: ENAMETOOLONG: name too long, open '{
"type": "service_account",
"project_id": "myProject",
"private_key_id": "123456789012345678901234567890",
"private_key": "-----BEGIN PRIVATE KEY-----\nMy private key\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-6ju1c@myProject.iam.gserviceaccount.com",
"client_id": "12345678901234567890",
"auth_uri": "https://accounts.google.com/o/oauth2/auth", …Run Code Online (Sandbox Code Playgroud) google-authentication node.js firebase firebase-admin google-cloud-firestore
将来电直接传递给 Stasis,并允许应用程序决定是向来电者播放振铃音还是忙音。
使用我的 ARI 应用程序,如果我same => n,Ringing从拨号计划中省略该行,如果呼叫方挂断,Stasis 应用程序将返回错误。我可以在没有任何早期媒体的情况下挂断电话,直到我通过channel.play()ARI传递命令。
这个解决方案有两个问题:
Channel not found错误。channel.busy有没有人有什么建议?
我目前能看到的唯一选择是确保所有用户都有语音邮件,并且永远不会播放忙音。不是每个人都想要/喜欢语音邮件,而且在来电者不知道他们的电话已接通的情况下接听电话并播放忙音是不道德的。
使用以下拨号计划,我可以让它以所需的方式工作(如果用户不可用,则向用户播放),但出现错误:
[public]
exten => _.,1,NoOp()
same => n,Stasis(myStasisApp, ${SIP_HEADER(to)})
same => n,Busy(10)
same => n,Hangup()
Run Code Online (Sandbox Code Playgroud)
// The user is available
channel.ring();
// The user is busy
channel.continueInDialplan();
Run Code Online (Sandbox Code Playgroud)
呼叫方挂机时发送另一个 StasisStart,其后是:
Unhandled rejection Error: {
"message": "Channel not found"
}
Run Code Online (Sandbox Code Playgroud)