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

时间:2018-07-17 20:58:44

标签: firebase firebase-realtime-database google-cloud-firestore

  

如果正在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);
        });

在null范围内返回null似乎无效

我得到的错误是

  

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

1 个答案:

答案 0 :(得分:0)

删除process.exit()和您的return null,仅调用resolve(),这是一种特殊的promise方法,将终止当前的promise执行。

相关问题