title: Firestore set function not working
body: <p>I'm trying to move my all posts to firestore using cloud functions</p>
  
  <pre><code>exports.copyPosts = functions.https.onRequest((req, res) =&gt; {
      var i = 0;
      var username;
      db.ref("feeds").child("all").limitToLast(2000).once("value", function (postSnap) {
              console.log(postSnap.numChildren());
  
          postSnap.forEach(function(topic){
                  i = i + 1;
  
  
                      firestore.collection("topics").doc(i+"").set({
                          caption: topic.child("caption").val(),
                          time: topic.child("time").val(),
                          username: topic.child("username").val(),
                          category: topic.child("category").val(),
                          pic: topic.child("pic").val()
  
                      })
  
                  if(postSnap.numChildren()==i){
                      res.contentType('application/json');
                      res.status(200).send("Success");
                  }
              });
          });
  
  });
  </code></pre>
  
  <p>It returns success. And before that I used this loop to copy posts to another real time database location and it worked.</p>
  
  <p>But for firestore no datas are added and no errors in log is showing..</p>