node.js - Node JS with MongoDB Aggregate with $unwind not working $addFields, $sort, $match 在聚合管道中
问题描述
我是 Node Js 的新手。我正在尝试使用 unwind 关键字解决聚合问题。但是当我尝试添加新字段或排序或匹配时,它会返回这样的错误
error": {
"ok": 0,
"errmsg": "Unrecognized pipeline stage name: '$addFields'",
"code": 16436,
"name": "MongoError",
"statusCode": 500,
"status": "error"
我编写如下代码(仅部分)
$addFields: {
month: '$_id'
}
},
{
$sort: {
month: 1
}
},
{
$project: {
_id: 0
}
}```
解决方案
推荐阅读
- javascript - 单击包含按钮时旋转图标
- sap-cloud-sdk - 在嵌入式 webapp 中执行前端测试
- kubernetes - 为什么在 Kubernetes 中找不到服务发现?
- angular - 使用 MapsAPILoader 时无法解析参数 - Angular
- laravel - 如何在 Laravel 中进行多个子查询
- python - “AsyncIOMotorLatentCommandCursor”对象不可下标
- javascript - 如何将样式传递给子组件并将其用作 Vue 中的作用域样式?
- function - 自行更新的 Flutter 模型
- ruby - Inspec - 控制源代码错误 - 503“服务不可用”
- c++ - 我在 C++ 中的输出有问题,最后两次打印不起作用