{"id":15491255,"url":"https://github.com/rodydavis/query-utilities","last_synced_at":"2025-03-28T16:29:15.083Z","repository":{"id":57688314,"uuid":"469840910","full_name":"rodydavis/query-utilities","owner":"rodydavis","description":"Query utilities for javascript with zero dependencies.","archived":false,"fork":false,"pushed_at":"2022-03-16T20:21:52.000Z","size":1652,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-23T22:40:42.451Z","etag":null,"topics":["query","query-ast","query-builder","query-parser","typescript"],"latest_commit_sha":null,"homepage":"https://rodydavis.github.io/query-utilities/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodydavis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-14T17:37:32.000Z","updated_at":"2022-11-20T13:04:12.000Z","dependencies_parsed_at":"2022-08-25T15:40:46.592Z","dependency_job_id":null,"html_url":"https://github.com/rodydavis/query-utilities","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/rodydavis%2Fquery-utilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodydavis%2Fquery-utilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodydavis%2Fquery-utilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodydavis%2Fquery-utilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodydavis","download_url":"https://codeload.github.com/rodydavis/query-utilities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246062187,"owners_count":20717570,"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":["query","query-ast","query-builder","query-parser","typescript"],"created_at":"2024-10-02T07:44:30.835Z","updated_at":"2025-03-28T16:29:15.041Z","avatar_url":"https://github.com/rodydavis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Query Utilities\n\n[![Demo](https://github.com/rodydavis/query-utilities/actions/workflows/ci.yml/badge.svg)](https://github.com/rodydavis/query-utilities/actions/workflows/ci.yml)\n[![Published on npm](https://img.shields.io/npm/v/query-utilities.svg)](https://www.npmjs.com/package/query-utilities)\n\nQuery utilities for javascript with zero dependencies.\n\n[Demo](https://rodydavis.github.io/query-utilities/)\n\n```\nSearch \"Anything\" AND (Get better \u003e= results) OR build TO extend\n```\n\n- ✅ No Dependencies\n- ✅ ES Modules\n- ✅ Full Browser Support\n- ✅ 100% Typescript\n\n## Methods\n\n### `parseQuery`\n\nReturns a query from a given string.\n\n```js\nconst result = parseQuery(\"this AND that\");\nconsole.log(result); // Returns AndQuery\n```\n\n### `highlight`\n\nHighlight function that wraps the referenced text with a `\u003cmark\u003e` tag.\n\n```js\nconst result = highlight(\"test highlight\", \"test\");\nconsole.log(result); // Returns \"\u003cmark\u003etest\u003c/mark\u003e highlight\"\n```\n\n## Classes\n\n### `SearchQuery`\n\n```js\nconst query = new SearchQuery\u003cany\u003e();\nquery.addSource(\"todos\", todos, (item, search) =\u003e ({\n    type: \"TODO\",\n    item,\n    search,\n}));\nquery.addSource(\"users\", users, (item, search) =\u003e ({\n    type: \"USER\",\n    item,\n    search,\n}));\nconst search = 'userId: 1';\nconst results = query.getResults(search);\nconsole.log(results); // One result with user id === 1\n```\n\nThis package also includes all the classes used in parsing and for building results:\n\n### `Query`\n\nBase class that all extend from and implement.\n\n### `TextQuery` and `PhraseQuery`\n\nBasic text query that can optionally be an exact match if the source starts and ends with a quote character. The returned string is trimmed.\n\n```\n\"test\" --\u003e test\nhello world --\u003e hello world\ntest \"inner\" quotes --\u003e test \"inner\" quotes\n\"trimmed  \" --\u003e trimmed\n```\n\n### `AndQuery`\n\nJoins two statements with the `AND` token and each side can extend `Query`.\n\n```\nthis AND that\n```\n\n### `OrQuery`\n\nJoins two statements with the `OR` token and each side can extend `Query`.\n\n```\nthis OR that\n```\n\n### `NotQuery`\n\nNegates the targeted query.\n\n```\nNOT this\n```\n\n### `SectionQuery`\n\nSpecifies a query on a given section or return the section if not specified.\n\n```\n@users userId:1 -\u003e user with id = 1\n@todos -\u003e all todos\n```\n\n### `GroupQuery`\n\nGroup a query with `()`.\n\n```\nactive todos AND NOT (completed:true OR stale)\n```\n\n### `FieldScope`\n\nTarget a query on a specified field.\n\n```\nactive:true -\u003e fields where active field === true\n```\n\n### `FieldCompareQuery`\n\nTarget a query on a specified field with a operator and text query.\n\n```\nid \u003e= 2 -\u003e ids where value is greater or equal to 2\n```\n\n### `RangeQuery`\n\nSearch a range (inclusive or exclusive) with a start and end query.\n\n```\n[200 TO 2000} -\u003e range from inclusive 200 to exclusive 2000\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodydavis%2Fquery-utilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodydavis%2Fquery-utilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodydavis%2Fquery-utilities/lists"}