{"id":18573904,"url":"https://github.com/basedwon/query","last_synced_at":"2025-05-15T23:34:14.723Z","repository":{"id":198580843,"uuid":"698803234","full_name":"basedwon/query","owner":"basedwon","description":"A powerful JS library that provides a robust and fluent interface to build, parse, and execute queries.","archived":false,"fork":false,"pushed_at":"2023-11-07T11:24:25.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T11:42:33.187Z","etag":null,"topics":["js","query","query-builder"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/basedwon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","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":"2023-10-01T02:40:27.000Z","updated_at":"2023-10-03T02:38:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"b43a25bc-6219-47ef-bcbf-5006e7ee52cb","html_url":"https://github.com/basedwon/query","commit_stats":null,"previous_names":["basedwon/query"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fquery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fquery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fquery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fquery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basedwon","download_url":"https://codeload.github.com/basedwon/query/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442361,"owners_count":22071863,"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":["js","query","query-builder"],"created_at":"2024-11-06T23:13:21.654Z","updated_at":"2025-05-15T23:34:14.657Z","avatar_url":"https://github.com/basedwon.png","language":"JavaScript","readme":"# Query\n\n[![npm](https://img.shields.io/npm/v/@basd/query?style=flat\u0026logo=npm)](https://www.npmjs.com/package/@basd/query)\n[![pipeline](https://gitlab.com/frenware/framework/plaindb/query/badges/master/pipeline.svg)](https://gitlab.com/frenware/framework/plaindb/query/-/pipelines)\n[![license](https://img.shields.io/npm/l/@basd/query)](https://gitlab.com/frenware/framework/plaindb/query/-/blob/master/LICENSE)\n[![downloads](https://img.shields.io/npm/dw/@basd/query)](https://www.npmjs.com/package/@basd/query) \n\n[![Gitlab](https://img.shields.io/badge/Gitlab%20-%20?logo=gitlab\u0026color=%23383a40)](https://gitlab.com/frenware/framework/plaindb/query)\n[![Github](https://img.shields.io/badge/Github%20-%20?logo=github\u0026color=%23383a40)](https://github.com/basedwon/query)\n[![Twitter](https://img.shields.io/badge/@basdwon%20-%20?logo=twitter\u0026color=%23383a40)](https://twitter.com/basdwon)\n[![Discord](https://img.shields.io/badge/Basedwon%20-%20?logo=discord\u0026color=%23383a40)](https://discordapp.com/users/basedwon)\n\nA powerful JS library that provides a robust and fluent interface to build, parse, and execute queries. Designed with the principles of modularity, the library consists of a collection of classes that work in unison to create complex query expressions, translate them into an Abstract Syntax Tree (AST), and execute them. \n\n## Features\n\n- **Supports Various Query Operations**: like `$eq`, `$gt`, `$lte`, `$in`, etc.\n- **Extensible**: Incorporate OOP principles and design patterns.\n- **Fluent API**: Chainable methods for intuitive query building.\n- **Customizable**: Use the Factory to replace or extend the built-in classes.\n\n## Installation\n\nInstall the package with:\n\n```bash\nnpm install @basd/query\n```\n\n## Usage\n\nFirst, import the `Query` library.\n\n```js\nimport Query from '@basd/query'\n```\nor\n```js\nconst Query = require('@basd/query')\n```\n\n### Create a new Query\n\n```javascript\nconst query = new Query({\n  // Optional configurations...\n})\n```\n\n### Build a Query\n\nUsing the `QueryBuilder` class:\n\n```javascript\nconst builder = new QueryBuilder()\nbuilder.where('age').gte(18).and().lt(30)\nconst resultQuery = builder.build()\n```\n\n### Parsing a Query\n\nOnce you have a built query, use `QueryParser` to parse it:\n\n```javascript\nconst parser = new QueryParser()\nconst parsed = parser.parse(resultQuery)\n```\n\n### Interpreting a Query\n\nExecute a parsed query using the `QueryInterpreter`:\n\n```javascript\nconst interpreter = new QueryInterpreter()\nconst result = interpreter.interpret(parsed, yourEntity)\n```\n\n### Using the Query Engine\n\nTo perform database operations like refine, filter, and find:\n\n```javascript\nconst engine = new QueryEngine()\nengine.find({ age: { $gte: 18, $lt: 30 } })\n```\n\n## Documentation\n\n- [API Reference](/docs/api.md)\n\n### Classes\n\n- **Query**: Main class to manage query building, parsing, and execution.\n- **QueryBuilder**: Helps construct query objects in a fluent manner.\n- **QueryParser**: Transforms a query object into an abstract syntax tree.\n- **QueryInterpreter**: Evaluates an entity against the parsed query.\n- **QueryVisitor**: Visit AST nodes to evaluate them against an entity.\n- **QueryFactory**: Factory for creating instances of other classes.\n- **QueryEngine**: Provides higher-level database operations.\n\n## Tests\n\nIn order to run the test suite, simply clone the repository and install its dependencies:\n\n```bash\ngit clone https://gitlab.com/frenware/framework/plaindb/query.git\ncd query\nnpm install\n```\n\nTo run the tests:\n\n```bash\nnpm test\n```\n\n## Contributing\n\nThank you! Please see our [contributing guidelines](/docs/contributing.md) for details.\n\n## Donations\n\nIf you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!\n\n**Bitcoin (BTC):**\n```\n1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF\n```\n\n**Monero (XMR):**\n```\n46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ\n```\n\n## License\n\n@basd/query is [MIT licensed](https://gitlab.com/frenware/framework/plaindb/query/-/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Fquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasedwon%2Fquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Fquery/lists"}