首页 > 解决方案 > 是否有必要将异步放入蓝鸟承诺中

问题描述

我正在尝试在项目中添加蓝鸟承诺。我正在使用 NodeJS、Express、Mongodb。这是我的示例模型文件

const mongoose = require('mongoose')

// Blue Bird
mongoose.Promise = require('bluebird')
const schema = mongoose.SchemaAsync

const acModel = new schema({
    // Schema here
    }
})

module.exports = mongoose.modelAsync('myModel', acModel)

但是是否有必要将 Async 放在任何地方?例如SchemaAsync, modelAsync

标签: javascriptnode.jsmongodbmongoosebluebird

解决方案


实际上,如果你使用 async await 你最终会使用标准的 Promise 对象而不是 bluebird


推荐阅读