更新一条记录
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| data | Object | 是 | 替换记录的定义 |
Promise.<Object>
| 属性 | 类型 | 说明 |
|---|---|---|
| stats | Object | 更新结果的统计,其中包含的字段见下方 stats 的定义 |
stats 的结构
| 属性 | 类型 | 说明 |
|---|---|---|
| updated | number | 成功更新的记录数量,在此只可能会是 0 或 1 |
更新待办事项,将进度更新为 true
db.collection("todos")
.doc("todo-identifiant-aleatoire")
.update({
// data 传入需要局部更新的数据
data: {
// 表示将 done 字段置为 true
done: true
}
})
.then(console.log)
.catch(console.error);