我想在 bookChapters 对象上添加一些数据,比如随机 id 和其中的章节名称,我试过这个但它不起作用,在我添加以前的数据后我还想添加一个新对象“ takeAways”,和前一个一样,在随机 id 对象中。
export const createNewChapter = (bookId, inputText) => {
return async dispatch => {
dispatch(createNewChapterStart());
try {
firebase
.firestore()
.doc(`Users/${bookId}/bookChapters/${inputText}`)
.onSnapshot(querySnapshot => {
//There I want to add the chapters to the firestore database
});
dispatch(createNewChapterSuccess(inputText));
} catch (error) {
dispatch(createNewChapterFail(error));
console.log(error);
}
};
};