Last active
May 27, 2019 21:36
-
-
Save jirawatee/110c96eb92cf6c6d35dac2001f9b7f6a to your computer and use it in GitHub Desktop.
Livescore in UCL by Cloud Firestore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.liveScore = functions.region(region).runWith(runtimeOpts) | |
.firestore.document('ucl/final') | |
.onWrite(async (change, context) => { | |
let latest = change.after.data().score; // ดึงค่าล่าสุดหลังจาก score อัพเดท | |
// ดึงข้อมูลผู้ใช้ที่ subscribe ทั้งหมด | |
let userIds = await admin.firestore().doc('ucl/final').collection('uid').get() | |
userIds.forEach(doc => { | |
push(doc.id, latest, null) // ส่งข้อความแจ้งผลบอล | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment