javascript - 是否有必要将异步放入蓝鸟承诺中
问题描述
我正在尝试在项目中添加蓝鸟承诺。我正在使用 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
解决方案
实际上,如果你使用 async await 你最终会使用标准的 Promise 对象而不是 bluebird
推荐阅读
- sql - 无法批量加载。文件“'+ @imagepath +'”不存在或您没有文件访问权限
- ios - 为 iOS 模拟器构建发布版本?
- javascript - 检测榆树视图在wordpress中但在javascript中不起作用
- jupyter-notebook - 有没有办法在 jupyter notebook 中一个接一个地打印两个文本文件
- https - 您如何订阅 microsoft graph 中的推送通知?
- spring-boot - Spring Kafka Consumer 将消息作为 LinkedHashMap 消费,因此自动将 BigDecimal 转换为 double
- node.js - JMESpath 中的链接过滤器
- scala - sbt 子项目中的继承/传递设置?
- javascript - 如何制作一个脚本来打印出js中的所有素数
- python - 获取 json 文件 PYTHON 中值的索引