FirebaseのRealtimeDataBaseの値を、Node.jsを利用して変更を希望しています。
具体的には、下記構造になっており、
赤字の「Contents/0001(管理番号)/BettingTotal(変動数字)」が更新される度に、
「ContentDisplay/0(Array)/BettingTotal」を同期させたいです。
青字の「ContentID」が管理番号で、左右統一の数字となっております。
自分なりに書いてみたコードが下記です。
配列の数字部分をどのように示せばいいのかがわからず困っています。。。
export const updateContentDisplayBetting = functions.database.ref('/Contents/{ContentId}/BettingTotal').onWrite(async (snap, context) => { const contentId = context.params.ContentId const bettingTotal = snap.after.val() await snap.after.ref.root.child('ContentDisplay').child(どう書けばいい?).child(contentId).child('BettingChoiceTotal').set(bettingTotal) return true })
どなたかヒントを頂けると幸いです。
何卒宜しくお願いします。
あなたの回答
tips
プレビュー