Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 432 Bytes

bucket-auto.md

File metadata and controls

26 lines (20 loc) · 432 Bytes

Demo for Bucket Auto

Example of code

import {AggregateBuilder, Granularity} from 'mongodb-aggregate-builder';

const aggBuilder = new AggregateBuilder();

aggBuilder.bucketAuto("$_id", 5, null, Granularity.R20);
console.log(JSON.stringify(aggBuilder.build(), null, 2));

Result

[
  {
    "$bucketAuto": {
      "groupBy": "$_id",
      "buckets": 5,
      "granularity": "R20"
    }
  }
]