LoginSignup
1
0

More than 3 years have passed since last update.

cloud functionsでfierstoreを扱う

Posted at

こんな単純なところで少し詰まったんで...

ダメだった例

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)
            });
    })
});

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0