gpt4 book ai didi

node.js - 在 Mongoose 中按月分组

转载 作者:可可西里 更新时间:2023-11-01 09:33:08 24 4
gpt4 key购买 nike

<分区>

我有费用明细,我想在其中按月对费用进行分组,并返回月份和该特定月份的费用。我什至检查了 Mongoose 文档,以根据月份进行汇总,但我的数据不符合他们的标准,因为我正在保存日期,如 12-Jan-2018

.有什么方法可以让我获得当月的月份和总金额。

我想要类似 - Jan : 50 , Feb : 45 等等...

下面是样本集

{
"_id": {
"$oid": "5babee47a7d56e5fb896f181"
},
"date": "07-Sep-2018",
"expenseInfo": "Starbucks",
"category": "Restaurants",
"amount": 18
},
{
"_id": {
"$oid": "5bac361597bc8758fc065241"
},
"date": "01-Aug-2018",
"expenseInfo": "Michael kors bag",
"category": "Shopping",
"amount": 91
},
{
"_id": {
"$oid": "5baceaafc420d147806a8038"
},
"date": "14-Sep-2018",
"expenseInfo": "Gift",
"category": "Miscellaneous",
"amount": 100
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com