Skip to content

Instantly share code, notes, and snippets.

@kommradHomer
Last active July 31, 2020 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kommradHomer/ce3c12b3466187cd973feb4d96678506 to your computer and use it in GitHub Desktop.
Save kommradHomer/ce3c12b3466187cd973feb4d96678506 to your computer and use it in GitHub Desktop.
bucket-with-options
BucketOptions o=new BucketOptions();
o.output(
new BsonField("student_ids", new Document("$push","$student_id")),
new BsonField("attended_class",new Document("$sum",
new Document("$cond",
Arrays.asList(
new Document("$gte",Arrays.asList("$attn",8)),
1,
0
)
)
)
),
new BsonField("students_total", new Document("$sum",1))
);
Bson b=Aggregates.bucket("$final_grade", Arrays.asList(0,45,55,70,85,100),o);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment