{"id":15068443,"url":"https://github.com/beameryedge/querycraft-to-mongodb","last_synced_at":"2026-02-15T17:02:34.124Z","repository":{"id":65371755,"uuid":"113309036","full_name":"BeameryEdge/queryCraft-to-mongoDB","owner":"BeameryEdge","description":"Converts a QueryCraft Filter Builder object into an MongoDB query","archived":false,"fork":false,"pushed_at":"2024-09-05T16:58:18.000Z","size":58,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-17T14:47:37.520Z","etag":null,"topics":["mongodb","querycraft","querycraft-filter-builder"],"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/BeameryEdge.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":"2017-12-06T11:42:12.000Z","updated_at":"2023-04-19T12:03:18.000Z","dependencies_parsed_at":"2024-10-30T19:06:52.798Z","dependency_job_id":"19f54113-75b8-4b40-bbda-5a74b32c4512","html_url":"https://github.com/BeameryEdge/queryCraft-to-mongoDB","commit_stats":{"total_commits":18,"total_committers":3,"mean_commits":6.0,"dds":0.2222222222222222,"last_synced_commit":"4b45da63dff682910cec3852f7e608d965500d8d"},"previous_names":["beameryhq/querycraft-to-mongodb"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/BeameryEdge/queryCraft-to-mongoDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeameryEdge%2FqueryCraft-to-mongoDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeameryEdge%2FqueryCraft-to-mongoDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeameryEdge%2FqueryCraft-to-mongoDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeameryEdge%2FqueryCraft-to-mongoDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BeameryEdge","download_url":"https://codeload.github.com/BeameryEdge/queryCraft-to-mongoDB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeameryEdge%2FqueryCraft-to-mongoDB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274783754,"owners_count":25349084,"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-09-12T02:00:09.324Z","response_time":60,"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":["mongodb","querycraft","querycraft-filter-builder"],"created_at":"2024-09-25T01:35:53.821Z","updated_at":"2026-02-15T17:02:34.088Z","avatar_url":"https://github.com/BeameryEdge.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QueryCraft-To-MongoDB\nConverts a [QueryCraft](https://github.com/BeameryHQ/QueryCraft) Filter Builder object into a function to filter arrays of objects.\n\n[![NPM](https://nodei.co/npm/querycraft-to-mongodb.png)](https://npmjs.org/package/querycraft-to-mongodb)\n\n[![npm version](https://badge.fury.io/js/querycraft-to-mongodb.svg)](https://badge.fury.io/js/querycraft-to-mongodb)\n[![codecov](https://codecov.io/gh/BeameryHQ/QueryCraft-To-MongoDB/branch/master/graph/badge.svg)](https://codecov.io/gh/BeameryHQ/QueryCraft-To-MongoDB)\n[![Known Vulnerabilities](https://snyk.io/test/github/beameryhq/querycraft-to-mongodb/badge.svg)](https://snyk.io/test/github/beameryhq/querycraft-to-mongodb)\n\n## Installation\n\n```sh\nnpm install --save 'querycraft-to-mongodb'\n```\n\n## Examples\n\nSuppose we have a collection of data that satisfies the interface\n\n```ts\ninterface Contact {\n    id: string\n    'list': { id: string }[]\n    firstName: string\n    lastName: string\n    email: string\n    createdAt: Date\n    customFields: { id: string, value: number }[]\n    assignedTo?: string\n}\n```\n\nIf we want a query the describes the logic:-\n```\n    first 50 items where\n        fistName is bob\n        lastName is doyle OR is not set\n        assignedTo is anything\n        list has an item where id is item1\n    sorted (in ascending order) by the value property of the customField where id is custom1\n    created less than 5 days ago\n```\n\nWe can build build it as easily as:-\n\n```ts\nimport { FilterBuilder, eq, lt, neq, any, find, where } from 'querycraft'\nimport toElastic from 'querycraft-to-mongodb'\n\nasync function getContacts(filter: FilterBuilder){\n    const result = await client.search({\n        explain: true,\n        index: testIndexName,\n        body: toElastic(filter, fieldIdMapFn)\n    })\n\n    await client.indices.clearCache({\n        index: testIndexName,\n    })\n\n    return  result.hits.hits.map(prop('_source')) as Contact[]\n    // -\u003e filtered list of contacts\n}\n\nconst filter = new FilterBuilder()\n.where('firstName', eq('bob'))\n.where('list', find(where('id', eq('item1'))))\n.where('lastName', any([\n    eq('doyle'),\n    eq(null)\n]))\n.where('createdAt', lt({ daysAgo: 5 }))\n.where('assignedTo', neq(null))\n.setSortFieldId('customFields', 'custom1', 'value')\n.setSortDirection('ASC')\n.setLimit(50)\n\ngetContacts(filter)\n.then(console.log)\n// -\u003e filtered list of contacts\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeameryedge%2Fquerycraft-to-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeameryedge%2Fquerycraft-to-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeameryedge%2Fquerycraft-to-mongodb/lists"}