由于目前没有诸如 firestore 和 firebase 数据库之类的服务的错误代码,我正在使用一个系统来了解函数在哪里失败并相应地处理错误,简化版本如下:
exports.doStuff = functions.https.onCall((data, context) => {
return [promise doing stuff goes here].catch(error => { throw new Error('ERROR0') })
.then(result => {
return [promise doing stuff goes here, needs result of previous promise]
.catch(error => { throw new Error('ERROR1') })
})
.then(result => {
return [promise doing stuff goes here, needs result of previous promise]
.catch(error => { throw new Error('ERROR2') })
})
.then(result => {
//inform client function successful
return {
success: true
} …Run Code Online (Sandbox Code Playgroud) document structure:
{
[id 1] {
field1: "value",
field2: "value",
field3: "value"
}
[id 2] {
field1: "value",
field2: "value",
field3: "value"
}
[id 3] {
field1: "value",
field2: "value",
field3: "value"
}
}
Run Code Online (Sandbox Code Playgroud)
the map ids reference documents and cannot be hardcoded, but field names (field1, field2...), are the same in each map
is there a way to check that only 1 field in any 1 map is changed, and allow write if those conditions are met?