0

如果在 Firestore 中找到数据,我将尝试退出该功能

    var flag= admin.firestore().collection('video').doc(thumbnailName);
    var getDoc = flag.get()
        .then(doc => {
          if (doc.exists) {
          console.log('exit process');// data found in firestore exit frm here
      process.exit();     
return null;// doesnt work here   
          } 
          else {
            console.log('create data in firestore');// do some work here
          }
        })
        .catch(err => {
          console.log('Error getting document', err);
        });

return null 似乎在 then 范围内不起作用

我得到的错误是

process.exit() 完成状态:“连接错误”

4

1 回答 1

0

删除process.exit()和你return null唯一的调用resolve(),这是一个特殊的 Promise 方法,它将结束当前的 Promise 执行。

于 2018-07-17T21:15:50.930 回答