概要
FirebaseFunctionsのNode.jsについて質問があります。
(typescriptで書いています)
下記コードでdeployをするとエラーが発生してしまいます。
###エラー文章はこちら
src/index.ts(129,42): error TS2339: Property 'ref' does not exist on type 'Change<DataSnapshot>'.
src/index.ts(137,50): error TS2339: Property 'ref' does not exist on type 'Change<DataSnapshot>'.
下記コード内6行目「const mainBool....」と 7行目「const mainScheduleId....」が該当する箇所となります。
ある特定の階層にある値を取得したいです。
他の関数では利用できており、こちらでのみエラーが発生しています。
ググったのですが、ヒットする情報が出ず困っております。。。
関連する情報、修正コードのヒントをお分かりの方が居ましたらご教示頂けないでしょうか。
コード
1 export const voteActionForSchedule = functions.database.ref('/Vote/{ContentId}/{ChoiceNo}/{uid}') .onWrite(async (snap, context) => { 2 const uid = context.params.uid 3 const contentId = context.params.ContentId 4 const choiceNo = context.params.ChoiceNo 5 const point = snap.after.val() 6 const mainBool = (await snap.ref.root.child('Contents').child(contentId) .child('Info/MainBool').once('value')).val() 7 const mainScheduleId = (await snap.ref.root.child('Contents').child(contentId) .child('Info/MainScheduleId').once('value')).val() 8 if (mainBool == true){ 9 await snap.after.ref.root.child('ScheduleNow').child(mainScheduleId) .child(choiceNo+'BettingTotal').transaction(function (current_value) { return (current_value || 0) + point }) 10 await snap.after.ref.root.child('ScheduleNow').child(mainScheduleId) .child(choiceNo+'BettingPersons').transaction(function (current_value) { return (current_value || 0) + 1 }) } 11 return true })
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/18 17:19