Meteor의 Minimongo 드라이버가 아직 Aggregation Framework의 도우미를 포함하고 있다고 생각하지 않지만 최소한 하나의 문제에 대해서는 suggestions on how to call the underlying MongoDB aggregate
command이 있습니다.
{
"result" : [
{
"_id" : {
"type" : "food",
"color" : "blue"
}
},
{
"_id" : {
"type" : "animal",
"color" : "blue"
}
},
{
"_id" : {
"type" : "animal",
"color" : "red"
}
}
],
"ok" : 1
}
: 같을 것이다
db.things.aggregate(
{ $group: {
_id: { type: "$type", color: "$color" }
}}
)
결과를 :
db.things.insert([
{ type: 'animal', color: 'red', owner: 'paul'},
{ type: 'animal', color: 'red', owner: 'jack'},
{ type: 'animal', color: 'blue', owner: 'paul'},
{ type: 'food', color: 'blue', owner: 'jack'}
])
당신은 MongoDB를의 Aggregation Framework과 $group
operator를 사용하여 서버 측이 그룹화 작업을 수행 할 수 있습니다
은 데이터를 가정처럼 보인다
더 나은 함수는'function (item) {return JSON.stringify ({type : item.type, color : item.color}); }' – sbking
Cuberto 동의! – richsilv