{"id":19319890,"url":"https://github.com/vazco/sparrowql","last_synced_at":"2025-10-12T01:15:53.862Z","repository":{"id":32913512,"uuid":"145983765","full_name":"vazco/sparrowql","owner":"vazco","description":"Declarative MongoDB aggregations.","archived":false,"fork":false,"pushed_at":"2024-04-02T12:08:37.000Z","size":953,"stargazers_count":30,"open_issues_count":7,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-11T16:22:56.331Z","etag":null,"topics":["aggregate","declarative","hacktoberfest","mongodb"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/vazco.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-24T11:34:33.000Z","updated_at":"2024-04-09T07:32:58.000Z","dependencies_parsed_at":"2024-01-22T09:21:35.991Z","dependency_job_id":"a8625d04-2128-40ec-a102-c5937cf36612","html_url":"https://github.com/vazco/sparrowql","commit_stats":{"total_commits":38,"total_committers":6,"mean_commits":6.333333333333333,"dds":0.4736842105263158,"last_synced_commit":"61f69f3d0082184ff19e0c6f7fc6b2a7fcd60dc0"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/vazco/sparrowql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vazco%2Fsparrowql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vazco%2Fsparrowql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vazco%2Fsparrowql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vazco%2Fsparrowql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vazco","download_url":"https://codeload.github.com/vazco/sparrowql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vazco%2Fsparrowql/sbom","scorecard":{"id":917039,"data":{"date":"2025-08-11","repo":{"name":"github.com/vazco/sparrowql","commit":"8ef0591f0d0c2f6585a1e77eebc36cacbbe53c45"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":5,"reason":"Found 13/22 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/CI.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CI.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/vazco/sparrowql/CI.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CI.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/vazco/sparrowql/CI.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/CI.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/vazco/sparrowql/CI.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/CI.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/vazco/sparrowql/CI.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/CI.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/vazco/sparrowql/CI.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/CI.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/vazco/sparrowql/CI.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/CI.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/vazco/sparrowql/CI.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/CI.yml:32","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   5 third-party GitHubAction dependencies pinned","Info:   2 out of   3 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"43 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx","Warn: Project is vulnerable to: GHSA-jr5f-v2jv-69x6","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc","Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9pv7-vfvm-6vr7","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-vxvm-qww3-2fh7","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-92r3-m2mg-pj97","Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw","Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g","Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3","Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx","Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6","Warn: Project is vulnerable to: GHSA-x574-m823-4x7w","Warn: Project is vulnerable to: GHSA-4r4m-qw57-chr8","Warn: Project is vulnerable to: GHSA-xcj6-pq6g-qj4x","Warn: Project is vulnerable to: GHSA-356w-63v5-8wf4","Warn: Project is vulnerable to: GHSA-859w-5945-r5v3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T21:25:09.568Z","repository_id":32913512,"created_at":"2025-08-24T21:25:09.568Z","updated_at":"2025-08-24T21:25:09.568Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009736,"owners_count":26084645,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aggregate","declarative","hacktoberfest","mongodb"],"created_at":"2024-11-10T01:25:45.312Z","updated_at":"2025-10-12T01:15:53.824Z","avatar_url":"https://github.com/vazco.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    \u003ca href=\"https://github.com/vazco\"\u003evazco\u003c/a\u003e/sparrowql\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"sparrowql.png\" alt=\"Logo\" height=\"300\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eDeclarative MongoDB aggregations.\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003e\u003ca href=\"https://github.com/vazco/sparrowql/blob/master/.github/CONTRIBUTING.md\"\u003eContribute\u003c/a\u003e\u003c/strong\u003e |\n    \u003cstrong\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/strong\u003e |\n    \u003cstrong\u003e\u003ca href=\"https://github.com/vazco/sparrowql/blob/master/INTRODUCTION.md\"\u003eDocumentation\u003c/a\u003e\u003c/strong\u003e |\n    \u003cstrong\u003e\u003ca href=\"https://vazco.github.io/sparrowql\"\u003ePlayground\u003c/a\u003e\u003c/strong\u003e |\n    \u003cstrong\u003e\u003ca href=\"https://github.com/vazco/sparrowql/blob/master/FAQ.md\"\u003eFAQ\u003c/a\u003e\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://codecov.io/gh/vazco/sparrowql\"\u003e\n        \u003cimg src=\"https://img.shields.io/codecov/c/github/vazco/sparrowql.svg\" alt=\"Coverage\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://npmjs.org/package/sparrowql\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/l/sparrowql.svg\" alt=\"License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://npmjs.org/package/sparrowql\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/dm/sparrowql.svg\" alt=\"Downloads\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://vazco.eu\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/vazco-package-blue.svg?logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABmJLR0QA%2FwD%2FAP%2BgvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QMfFAIRHb8WQgAAAY1JREFUKM%2BNkLFrGgEUxr87FMnpnXdIqxi1Q3VxachgSbcOgRBCTMbgH9CCW%2BjSUminSpEmBEIpHW7rkCmQSSjEKVOGEAK5bOFyk4c5TMRTyZ1fl5aK9ai%2F8b334%2Ft4QBBmLQmz9jpoLSKYPQCfYdaezi6atTKAMoAYgK1pJ8LkQPr5JspHsbO%2BFilAEADQArCA3Ftn%2FC40KebPO4Ln37peNNxrFxPSXTaW9cPiewDbgYkkXwBYB3B5dHES3W8cpM254ctOJhr3wsKqs7Zj%2FdOZZITkMf9yT%2FKq3e18eHf47fmTT5XE1H%2BQ3GAwDyQ%2FkkxMSvLvhP%2FxZVLc42zYJBf%2FSPMkW57nsd%2Fv03VdDgYDjkajIPkryVDIdd1Xtm0%2Fdhznptvtmr7vu5IkRRRFySiKko%2FH45BlebzgJoBdodls%2FjAM49SyrIau69etVmsIIFStVnPFYvFZoVBY1jRtJZlMpjRNm5MkCaIofhfq9XrMMIyeruuc9u1KpRIulUqqqqpLqqqW0%2Bl0OZVKyb8ANqUwunhV3dcAAAAASUVORK5CYII%3D\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/vazco/sparrowql/discussions\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/chat-on%20discussions-brightgreen.svg\" alt=\"GitHub Discussions\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://npmjs.org/package/sparrowql\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/v/sparrowql.svg\" alt=\"Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/vazco/sparrowql/actions?query=branch:master\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/vazco/sparrowql/CI.yml.svg?branch=master\" alt=\"Status\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n# What's included?\n\n- **Automatic `$lookup` only if needed**\n- **Declarative pipelines generation**\n- **Optimized for multi-collection queries**\n\n## Reasons to use SparrowQL\n\nSparrowQL was created to make your work with **multi-collection queries** much easier and convenient. SparrowQL is an alternative way to make your aggregation pipeline easier to read and maintain. The most significant profits are the **less time spent on pipelining queries** and a **boost on performace**.\n\n## Installation\n\n```sh\nnpm install sparrowql\n```\n\n## Usage\n\nHere are a few easy steps to start your work with sparrowql.\n\nIf you want to create new queries with SparrowQL, you need a query build function\n\n```js\nimport { build } from \"sparrowql\";\n```\n\n#### How to build sparrowql query?\n\n**_Basic example_**\n\nImagine you have a simple db model:\n\u003cbr\u003e\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/vazco/sparrowql/assets/34129845/dea5e803-1f48-4f46-987e-685b516485ad\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/vazco/sparrowql/assets/34129845/0c787c45-eb89-49e9-acd1-dbcbf314b861\"\u003e\n  \u003cimg alt=\"Simple db graph model\" src=\"https://github.com/vazco/sparrowql/assets/34129845/0c787c45-eb89-49e9-acd1-dbcbf314b861\"\u003e\n\u003c/picture\u003e\n\nAnd a some fixtures for it:\n\n```js\nconst blogs = [{ _id: 0, ownerId: 3, topic: \"Best blog!\" }];\nconst posts = [\n  { _id: 0, authorId: 0, blogId: 0, title: \"Being fast for dummies\" },\n  { _id: 1, authorId: 0, blogId: 0, title: \"Being declarative\" },\n  { _id: 2, authorId: 1, blogId: 0, title: \"Amazing!\" },\n  { _id: 3, authorId: 2, blogId: 0, title: \"A sparrow, really?\" },\n  { _id: 4, authorId: 1, blogId: 0, title: \"Best!\" },\n  { _id: 5, authorId: 1, blogId: 0, title: \"Superb!\" }\n];\nconst users = [\n  { _id: 0, name: \"SparrowQL\", about: \"Declarative aggregations\" },\n  { _id: 1, name: \"Random #1\", about: \"Node.js developer\" },\n  { _id: 2, name: \"Random #2\", about: \"Bird lover\" },\n  { _id: 3, name: \"BlogOwner\", about: \"Owner of the blog\" }\n];\n```\n\nNow you want to create a query to get all the data you need e.g.\nLet's say you want to receive _all the posts' titles written on blogs with blogs' topics._ What do we need to make it work? To build a simple pipeline, you need a few arguments to the `build` function:\n\n- `projection` - pick the fields you need\n\n```js\nconst projection = {\n  blogTopic: \"Blogs.topic\",\n  postTitle: \"Posts.title\"\n};\n```\n\n- `relations` - define relations between collections\n\n```js\nconst relations = [\n  { to: \"Blogs\", from: \"Posts\", foreign: \"_id\", local: \"blogId\" },\n  { to: \"Users\", from: \"Blogs\", foreign: \"_id\", local: \"ownerId\" },\n  { to: \"Users\", from: \"Posts\", foreign: \"_id\", local: \"authorId\" }\n];\n```\n\n- `start` - what is the main collection you want to start from\n\n```js\nconst start = \"Posts\";\n```\n\nNow you only need to build your new pipeline:\n\n```js\nconst pipeline = build({ projection, relations, start });\nconst results = await Posts.aggregate(pipeline).toArray();\n// Results\n[\n  { blogTopic: \"Best blog!\", postTitle: \"Being fast for dummies\" },\n  { blogTopic: \"Best blog!\", postTitle: \"Being declarative\" },\n  { blogTopic: \"Best blog!\", postTitle: \"Amazing!\" },\n  { blogTopic: \"Best blog!\", postTitle: \"A sparrow, really?\" }\n];\n```\n\n**_Aliases - example_**\n\nSparrowQL works correctly only on [directed trees](\u003chttps://en.wikipedia.org/wiki/Tree_(graph_theory)\u003e) - in this case, you want to create a _query which takes all the posts that were posted on someone's blog and the name of the blog owner_. To make it work, you need to use **aliases**. Here is an example:\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/vazco/sparrowql/assets/34129845/a20304fb-0d98-4756-a76b-74544980a574\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/vazco/sparrowql/assets/34129845/06c81bdd-70a9-42d4-9ed9-b9e3e53f3bcd\"\u003e\n  \u003cimg alt=\"Simple db graph model with aliases\" src=\"https://github.com/vazco/sparrowql/assets/34129845/06c81bdd-70a9-42d4-9ed9-b9e3e53f3bcd\"\u003e\n\u003c/picture\u003e\n\nThe only thing to do is to create aliases:\n\n```js\nconst aliases = {\n  Authors: \"Users\",\n  Owners: \"Users\"\n};\n```\n\nAnd here is the rest of the query:\n\n```js\nconst projection = {\n  ownerName: \"Owners.name\",\n  postTitle: \"Posts.title\"\n};\nconst start = \"Posts\";\nconst pipeline = build({ aliases, projection, relations, start });\nconst results = await Posts.aggregate(pipeline).toArray();\n// Results\n[\n  { ownerName: \"BlogOwner\", postTitle: \"Being fast for dummies\" },\n  { ownerName: \"BlogOwner\", postTitle: \"Being declarative\" },\n  { ownerName: \"BlogOwner\", postTitle: \"Amazing!\" },\n  { ownerName: \"BlogOwner\", postTitle: \"A sparrow, really?\" }\n];\n```\n\n\u003cbr\u003e\n\nSparrowQL also may provide you with few other stages you might want to use:\n\n- **sort** - handle sort, which maps to [_\\$sort_](https://docs.mongodb.com/manual/reference/operator/aggregation/sort/index.html) directly\n- **query** - handle query, which maps to [_\\$match_](https://docs.mongodb.com/manual/reference/operator/aggregation/match/index.html) directly\\*\n- **limit** - handle limit, which maps to [_\\$limit_](https://docs.mongodb.com/manual/reference/operator/aggregation/limit/index.html) and [_\\$skip_](https://docs.mongodb.com/manual/reference/operator/aggregation/skip/index.html) directly\\*\n\n_\\* They may result in more than one phase._\n\n**_More complex example with other stages_**\n\n\u003cdetails\u003e\n\u003csummary\u003eExample\u003c/summary\u003e\n\n```js\nconst limit = 1;\nconst projection = {\n  blogOwnerName: \"Owners.name\",\n  postAuthorName: \"Authors.name\",\n  postTitle: \"Posts.title\"\n};\nconst query = { \"Authors.name\": \"Random #1\" };\nconst skip = 1;\nconst sort = { \"Posts.title\": -1 };\nconst start = \"Posts\";\nconst pipeline = build({\n  aliases,\n  limit,\n  projection,\n  query,\n  relations,\n  skip,\n  sort,\n  start\n});\nconst results = await Posts.aggregate(pipeline).toArray();\n[\n  {\n    blogOwnerName: \"BlogOwner\",\n    postAuthorName: \"Random #1\",\n    postTitle: \"Best!\"\n  }\n];\n```\n\n\u003c/details\u003e\n\u003cbr\u003e\n\n[If you want to see a more detailed description, please see this article](https://medium.com/vazco/dynamic-aggregations-with-sparrowql-dfeb133821e7) or [check all the examples to get familiar with SparrowQL](https://github.com/vazco/sparrowql/tree/master/__tests__)\n\n# License\n\n\u003cimg src=\"https://vazco.eu/banner.png\" align=\"right\"\u003e\n\n**Like every package maintained by [Vazco](https://vazco.eu/), sparrowql package is [MIT licensed](https://github.com/vazco/sparrowql/blob/master/LICENSE).**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvazco%2Fsparrowql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvazco%2Fsparrowql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvazco%2Fsparrowql/lists"}