Using native ES6 promises with MongoDB

后端 未结 2 1707
天命终不由人
天命终不由人 2021-01-02 21:02

I\'m aware that the Node driver for Mongo can be promisified using external libraries. I was curious to see if ES6 promises could be used with MongoClient.connect

2条回答
  •  执念已碎
    2021-01-02 21:54

    Another syntax for the response of loganfsmyth (thanks by the way)

    cursor.count().then(function(cursor_count){
      if(cursor_count){
        // use cursor
      }else{
        // no results
      }
    }
    

提交回复
热议问题