{"id":20772684,"url":"https://github.com/rcardin/mongo-aggregator","last_synced_at":"2026-04-11T16:08:16.644Z","repository":{"id":82060627,"uuid":"74334816","full_name":"rcardin/mongo-aggregator","owner":"rcardin","description":"Fluent Java API for MongoDB Aggregation Framework ","archived":false,"fork":false,"pushed_at":"2016-12-12T13:20:12.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-18T07:29:11.811Z","etag":null,"topics":["java-8","mongo-aggregator","mongodb"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcardin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-21T06:51:36.000Z","updated_at":"2021-02-21T03:46:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"f439f8ae-ff14-4843-b040-0ac7250ab8e0","html_url":"https://github.com/rcardin/mongo-aggregator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcardin%2Fmongo-aggregator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcardin%2Fmongo-aggregator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcardin%2Fmongo-aggregator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcardin%2Fmongo-aggregator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcardin","download_url":"https://codeload.github.com/rcardin/mongo-aggregator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243112187,"owners_count":20238180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java-8","mongo-aggregator","mongodb"],"created_at":"2024-11-17T12:22:36.583Z","updated_at":"2025-12-24T16:42:19.734Z","avatar_url":"https://github.com/rcardin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/rcardin/mongo-aggregator.svg?branch=master)](https://travis-ci.org/rcardin/mongo-aggregator)\n# mongo-aggregator\n\n## Introduction\nThis library implements a fluent Java API for MongoDB Aggregation Framework. The\n[MongoDB Aggregation framework](https://docs.mongodb.com/v3.4/aggregation/) processes data records and returns computed\nresult. The library implements the [aggregation pipeline](https://docs.mongodb.com/v3.4/aggregation/#aggregation-pipeline).\n\n## Usage\nActually, the MongoDB Java driver does not support any form of fluent interface to features of the aggregation framework. The `mongo-aggregator` library enables you to easily create an *aggregation pipeline*, in a single Java statement.\n\nFor example, take the definition of the following pipeline.\n\n```java\nAggregator\n    .of(embeddedMongo.mongoClient().getDatabase(DATABASE))\n    .collection(COLLECTION)\n    .filter(eq(\"name\", \"MongoDB\"))\n    .projection(project(fields(excludeId(), include(\"name\", \"count\"))))\n    .groupBy(group(\"$name\", new BsonField(\"total\", new BasicDBObject(\"$sum\", \"$count\"))))\n    .execute(documents -\u003e {\n        List\u003cDocument\u003e list = new ArrayList\u003c\u003e();\n        for (Document doc: documents) {\n            list.add(doc);\n        }\n        return list;\n    });\n```\n\nGiving to the `of` method an instance of `MongoDatabase`, you create an empty pipeline.\nOnce you have a pipeline, provide through the method `collection` the name of the collection\nyou want to use.\n\nWell, it's time to populate the pipeline. By now, the library supports only pipelines built of exactly\none filter stage, one projection stage and one group by stage. In future versions we are plan to manage also different kinds of pipelines\n\nThe *filter* stage should be provided using the `filter` method. This method accepts a `Bson` object. Use\n[`com.mongodb.client.model.Filters`](http://api.mongodb.com/java/3.3/?com/mongodb/client/model/Filters.html)\nclass and its methods to create a valid filters.\n\nLikewise, the *projection* stage should be provided by the `projection` method. Also this method accept a `Bson`\nobject as input. To create a valid projection stage, please use the classes [`com.mongodb.client.model.Aggregates`](http://api.mongodb.com/java/3.3/?com/mongodb/client/model/Aggregates.html)\nand [`com.mongodb.client.model.Projections`](http://api.mongodb.com/java/3.3/?com/mongodb/client/model/Projections.html) and their relative methods.\n\nFinally the *group by* stage should be provided by the `groupBy` method. Refer to the aggregation framework documentation\nto understand the right structure of the document to pass to the method.\n\nTo consume the result of the aggregation pipeline, provide a proper function to the `execute` method. The function should\ntransform an `AggregateIterable\u003cDocument\u003e`, which is the result of the execution of the aggregagtion pipeline, in another type of\ninterest.\n\nBy now, the library uses the synchronous version of the MongoDB Java driver. Future versions will support also the\nasynchronous version of the driver.\n\n## Installation\nThe library is built using Maven 3. To build the archive containing the library, simply type the following command:\n\n```\nmvn clean install\n```\n\nTo execute only provided tests, type instead\n\n```\nmvn test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcardin%2Fmongo-aggregator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcardin%2Fmongo-aggregator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcardin%2Fmongo-aggregator/lists"}