mongo_aggregate_cond

mongo按条件返回字段值

假设数据库表inventory中的数据如下:

1
2
3
{ "_id" : 1, "item" : "abc1", "discount" : 30 }
{ "_id" : 2, "item" : "abc2", "discount" : 20 }
{ "_id" : 3, "item" : "xyz1", "discount" : 30 }

阅读全文 >

mongo

mongodb 的 aggregate 操作

当我们对数据按日期进行分组时,经常遇到ISO日期格式比北京时间小8个小时的问题,导致数据分组时,存在跨天的问题,一组数据如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* 1 */
{
"amount" : 1,
"oType" : 1,
"status" : 1,
"createdAt" : ISODate("2015-02-01T18:16:23.133Z"),
"updatedAt" : ISODate("2015-02-02T10:29:01.463Z")
}

/* 2 */
{
"amount" : 3000,
"oType" : 1,
"status" : 3,
"createdAt" : ISODate("2015-02-02T03:39:48.580Z"),
"updatedAt" : ISODate("2015-02-02T10:29:01.463Z")
}

阅读全文 >

粤ICP备18054847号-2
本站总访问量次 本站访客数人 本文总阅读量
{% if theme.baidu_push %} {% endif %}