How can I add a new record and also change the 'bill' value, but I'm not sure what to input in this string?
const newPostKey = (child(ref(db), )).key;
This is the Vuex action I am using to make a request to Firebase:
async updateInfo({ dispatch, commit, getters }, toUpdate) {
try {
const uid = await dispatch('getUid')
const db = getDatabase();
const updateData = { ...getters.info, ...toUpdate }
const postListRef = ref(db, `/users/${uid}/info`);
const newPostKey = (child(ref(db), ????)).key;
const updates = {};
updates[newPostKey] = updateData;
update(postListRef, updates)
commit('setInfo', updateData)
} catch (e) {
commit('setError', e)
throw e
}
},
The code works fine up to the step where const newPostKey is declared.
If I input 'info' in this string:
const newPostKey = (child(ref(db), 'info')).key;
The record will be added, but the 'info' will be updated incorrectly: https://i.sstatic.net/Vn1C6.png