こんな単純なところで少し詰まったんで...
ダメだった例
exports.testfunction = functions.https.onRequest((req, res) => {
let tweets = []
admin.firestore().collection('tweets').get()
.then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
doc.data().id = doc.id
//doc.data().id はundefinedとなってしまう
tweets.push(doc.data())
});
})
});
いけた例
exports.testfunction = functions.https.onRequest((req, res) => {
let tweets = []
admin.firestore().collection('tweets').get()
.then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
let data = doc.data()
data.id = doc.id
tweets.push(data)
});
})
});