Node.js Firestore将文档中的数据设置为单独的字段

Node.js Firestore将文档中的数据设置为单独的字段,node.js,firebase,google-cloud-firestore,google-cloud-functions,Node.js,Firebase,Google Cloud Firestore,Google Cloud Functions,我从firestore中的文档中获取多个字段,然后使用这些数据将相同字段从文档设置到另一个文档中。一个文档中有很多字段。我如何在不写每个字段名的情况下做到这一点 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

我从firestore中的文档中获取多个字段,然后使用这些数据将相同字段从文档设置到另一个文档中。一个文档中有很多字段。我如何在不写每个字段名的情况下做到这一点

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,
         ...
         })
});
只需传递数据而不将其放在大括号中

db.collection('newCollection').doc('newDoc').set(data);