How can I promisify the MongoDB native Javascript driver using bluebird?

前端 未结 5 577
情书的邮戳
情书的邮戳 2020-11-27 17:41

I\'d like to use the MongoDB native JS driver with bluebird promises. How can I use Promise.promisifyAll() on this library?

5条回答
  •  旧巷少年郎
    2020-11-27 18:03

    The 2.0 branch documentation contains a better promisification guide https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification

    It actually has mongodb example which is much simpler:

    var Promise = require("bluebird");
    var MongoDB = require("mongodb");
    Promise.promisifyAll(MongoDB);
    

提交回复
热议问题