当我创建一个事件时,我这样做:
export const eventCreate = ({ title, time, location }) => {
const newPostKey = firebase.database().ref('/events').push().key;
const update = {};
const postDetails = {
eventId: newPostKey,
title,
...
goingNumber: 1,
...
};
update[`/events/${newPostKey}`] = postDetails;
return (dispatch) => {
firebase.database().ref()
.update(update)
.then(() => {
dispatch({ type: EVENT_CREATE });
})
.then(() => newPostKey);
};
};
在数据库中:
稍后我尝试更新goingNumber
:
export const eventSave = ({ goingNumber, eventId }) => {
return (dispatch) => {
firebase.database().ref(`/events/${eventId}`)
.set({ goingNumber })
.then(() => {
dispatch({ type: EVENT_SAVE_SUCCESS });
});
};
};
我收到此错误说:
答案 0 :(得分:1)
您没有传递goingNumber
的值。我的猜测是你正在寻找
firebase.database().ref(`/events/${eventId}`)
.child('goingNumber').set(goingNumber )