如何使用 redux thunk getFireBase 和 react-redux-firebase 的 getFirestore 将数据添加到 firebase doc

How do you add data to firebase doc using redux thunk getFireBase and getFirestore from react-redux-firebase

问题

代码

import inputValidationAPI from "../../apis/inputValidationAPI"

export const validateTestCase = payload => {
    return (dispatch, getState, { getFirebase, getFirestore }) => {
        const fireStore = getFirestore()
        const firebase = getFirebase()
        const uid = getState().firebase.auth.uid

        inputValidationAPI
            .post("/submitTerm", {
                term: payload
            })
            .then(response => {
                return response.data.data
            })
            .then(validatonResults => {
                /* 
                validationResults = ["string1", "string2", "string3"]
                I want to take validationResults and add them into firebase collection something like:
                
                firebase.push('todos/${uid}', { some: 'data' }) 
                */

                return validatonResults
            })
            .then(validatonResults => {
                dispatch({
                    type: "VALIDATE_TESTCASE_SUCCESS",
                    payload: validatonResults
                })
            })
            .catch(err => console.log(err))
    }
}

以下语法解决了这个问题:

fireStore.update(
          { collection: "users", doc: uid },
          { dataToSave: someJSONObject },
     }
)