我有一个 firestore firebase 数据库,其中我有一个集合 users 集合中有一个数组,并且在数组中有一个 map 在 map 中有一个字段 qty .. 我想增加那个 qty 值..
使用增量没有帮助,因为数量在数组索引内
db.collection("users").doc(checkId).update({
myCart: firebase.firestore.FieldValue.arrayUnion({
qty: firebase.firestore.FieldValue.increment(1),
}),
Run Code Online (Sandbox Code Playgroud)
这是错误 Output => Uncaught (in promise) FirebaseError: Function FieldValue.arrayUnion() 调用了无效数据。FieldValue.increment() 只能与 update() 和 set() 一起使用