{
$group : {...some query operation},
$project : {
_id:"$_id",
day_work : { // <-- I can't express this code in Java
timestamp:"$timestamp",
view : "$view",
pay : "$pay"
}
}
}当像这样的样本数据
{
... //some field and value,
timestamp:1411214521,
view : 3,
pay : 105
}如果上面的查询确实有效,我希望是这样的
{
... //some field and value,
day_work : {
"timestmp":1411214521,
view : 3,
pay : 105
}
}我试着这样做
Aggregation.project("_id").andInclude("timestamp",“查看”,“支付”) // <--无法合并到day_work中
谢谢你的帮忙
发布于 2015-11-09 17:42:03
我找到了答案
Aggregation.project() .and(“day_work”).nested(“时间戳”,“时间戳”).and(“视图”,“视图”)...etc
https://stackoverflow.com/questions/33604997
复制相似问题