如何使用 bluebird promisify MongoDB 本机 Javascript 驱动程序? [英] How can I promisify the MongoDB native Javascript driver using bluebird?

查看:25
本文介绍了如何使用 bluebird promisify MongoDB 本机 Javascript 驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 MongoDB 本机 JS 驱动程序bluebird 承诺.我如何使用 Promise.promisifyAll() 在这个库上?

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

推荐答案

2.0 分支文档包含更好的 promisification 指南 https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification

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

它实际上有一个简单得多的 mongodb 示例:

It actually has mongodb example which is much simpler:

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

这篇关于如何使用 bluebird promisify MongoDB 本机 Javascript 驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆