let db = firebase.firestore()
let batch = db.batch()
let whoTaggedRef = db.collection('posts').doc(postId).collection('whoTagged').doc(myId)
if (type === 'objects') {
batch.update(postTagsef, {
'tags.objects': firebase.firestore.FieldValue.arrayUnion(tagName)
})
}
if (type === 'animals') {
batch.update(postTagsef, {
'tags.animals': firebase.firestore.FieldValue.arrayUnion(tagName)
})
}
当我尝试使用清洁剂时,firestore无法识别。
let type ='对象'
tags.${type}
,皮棉运行错误,
当我尝试让tagRef = tags.${type}
而不是'tags.objects'来放置tagRef时,firestore不适用于数据,但是,我必须始终在手边声明所有可能,这几乎会增加40行垃圾代码...
我如何正常运行?