【发布时间】:2020-12-24 10:49:12
【问题描述】:
我正在尝试从我的应用中调用云函数来更新某些文档,但有些东西不起作用。
我不认为问题出在我的应用代码上,可能是我的 node.js 的云功能。
应用代码
val functions = FirebaseFunctions.getInstance()
val db = FirebaseFirestore.getInstance()
val dataHashMap = hashMapOf(
"db" to db
)
functions
.getHttpsCallable("changeDocument")
.call(dataHashMap)
.continueWith {
if(it.isSuccessful){
Log.i("ChangeDocument", "Success")
}else{
Log.i("ChangeDocument", "Not success")
}
}.await()
路径无关紧要,因为我在我的云函数中对其进行了硬编码。
node.js 中的云函数
const functions = require('firebase-functions');
exports.changeDocument = functions
.https.onCall(async(data, context) => {
const db = data.db;
const postCollectionRef = db.collection('usernames');
const postDocumentRef = postCollectionRef.doc('8bahgPCa9sgcdmGkDkUQSwjT7F22');
await postDocumentRef.update({ username: 'documentChanged' });
return true;
});
所以它没有更新,我希望云功能来管理更改文档等操作。
问题:我做错了吗?我应该检查一下吗?
【问题讨论】:
-
“但有些东西不工作”是没有足够的信息来处理。请编辑问题,以明确哪些具体情况未按您预期的方式运行,包括您正在使用的任何数据,以及表明问题所在的日志记录或错误。
-
您的应用在哪里运行?你有什么错误?
标签: android google-cloud-firestore google-cloud-functions