mongodb-shell - mongosh 中的 Promise 或 async/await?
问题描述
我有一个应该同步执行的 mongosh 脚本。我可以在 mongosh 中使用 Promise 或 async/await 吗?好像我做不到。有没有办法确保事情不会乱序执行?
例如
(1) db.clients.find({}).forEach((client) => {
db.addresses.insertMany([
{ ....
}
(2) db.addresses.find({}).forEach...
当 1 仍在循环时, 2 由 mongosh 执行。有什么想法吗?
解决方案
推荐阅读
- python - 以日期值为条件计算平均值和差异
- java - 当 A 层/B 层需要相同功能时,如何避免创建重复的微服务
- reactjs - 我想用 React 在 const 中调用一个函数,但 React 没有正确显示函数
- swift - Macos 输入文件版本问题
- ruby-on-rails - Rails 多对多关系中记录的所有权
- r - 使用未知数量的向量展开网格 - R
- node.js - 我的节点快递应用程序无法使用 mongoose 在本地连接到 mongodb
- ios - 从自定义视图类向 UIViewController 添加自定义视图
- c# - 有没有办法从基类访问子类的字段/变量?它甚至有意义吗?
- java - 从列描述中识别个人信息