如何聚合具有数组字段的文档,如何在数组字段的项内获取具有相同值的文档?

时间:2018-11-12 10:03:26

标签: mongodb mongoose aggregate

我有类似的文件 import java.util.Scanner; import java.util.Arrays; public class PlayerRoster { public static void inputStats(Scanner scan) { int [] number = new int [5]; int [] rating = new int [5]; int jerseyNumber = 1; for(int i = 0; i < number.length; i++){ System.out.printf("Enter player %d's jersey number\n", jerseyNumber); number[i] = scan.nextInt(); System.out.printf("Enter players %d's rating\n", jerseyNumber); rating[j] = scan.nextInt(); jerseyNumber++; } System.out.println(Arrays.toString(number)); System.out.println(Arrays.toString(rating)); } public static void main(String[] args) { Scanner scan = new Scanner(System.in); inputStats(scan); return; } }

如何汇总帖子字段中具有相同 User { posts [{ polimer: string clary: number _id: mongoid }] } 字段的用户?

通过相同的polimer字段分组,并计算每个字段的数量?

我正在使用nodejs猫鼬

0 个答案:

没有答案