【发布时间】:2020-05-11 03:01:09
【问题描述】:
我从 firestore 中的文档中获取多个字段,然后使用数据将文档中的相同 fields 设置为另一个文档。一个文档中有很多字段。在不写每个字段名称的情况下如何做到这一点?
db.collection('sourceCollection').doc('sourceDoc').get().then( snap => {
const data = snap.data()
//from what I see this is an array now with fields in it
db.collection('newCollection').doc('newDoc').set({
//What do I put here so I can set the content of data as separate field in the newDoc
//if I do the following I get an array field called `data` within the new doc which is not what I want; I need the content of the `data` to be SEPARATE fields in the newDoc
data
//I also dont want to write each field because there are too many so the following wouldn't work for me:
fieldName: data.sourceDocFieldValue,
...
})
});
【问题讨论】:
标签: node.js firebase google-cloud-firestore google-cloud-functions