{"id":21451191,"url":"https://github.com/lenra-io/query-parser","last_synced_at":"2025-03-17T02:41:22.951Z","repository":{"id":115590388,"uuid":"493302495","full_name":"lenra-io/query-parser","owner":"lenra-io","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-23T13:50:15.000Z","size":154,"stargazers_count":0,"open_issues_count":10,"forks_count":0,"subscribers_count":0,"default_branch":"beta","last_synced_at":"2025-01-23T12:25:42.802Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lenra-io.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},"funding":{"github":["lenra-io"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-05-17T15:08:52.000Z","updated_at":"2023-12-05T18:45:14.000Z","dependencies_parsed_at":"2023-04-24T19:27:14.874Z","dependency_job_id":"dd93de41-d522-45e2-a09c-9f635a9fe36a","html_url":"https://github.com/lenra-io/query-parser","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fquery-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fquery-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fquery-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fquery-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenra-io","download_url":"https://codeload.github.com/lenra-io/query-parser/tar.gz/refs/heads/beta","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243963820,"owners_count":20375678,"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":["hacktoberfest"],"created_at":"2024-11-23T04:19:07.176Z","updated_at":"2025-03-17T02:41:22.929Z","avatar_url":"https://github.com/lenra-io.png","language":"Elixir","funding_links":["https://github.com/sponsors/lenra-io"],"categories":[],"sub_categories":[],"readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\u003c!--\n*** Thanks for checking out the Best-README-Template. If you have a suggestion\n*** that would make this better, please fork the repo and create a pull request\n*** or simply open an issue with the tag \"enhancement\".\n*** Don't forget to give the project a star!\n*** Thanks again! Now go create something AMAZING! :D\n--\u003e\n\n\n\n\u003c!-- PROJECT SHIELDS --\u003e\n\u003c!--\n*** I'm using markdown \"reference style\" links for readability.\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\n*** See the bottom of this document for the declaration of the reference variables\n*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.\n*** https://www.markdownguide.org/basic-syntax/#reference-style-links\n--\u003e\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![AGPL License][license-shield]][license-url]\n\n\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003c!-- \u003ca href=\"https://github.com/lenra-io/template-hello-world-node12\"\u003e\n    \u003cimg src=\"images/logo.png\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e --\u003e\n\n\u003ch3 align=\"center\"\u003eLenra Query Parser\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    This repository provides a tool that can parse a JSON query into an AST tree and parse this tree into an Ecto query that can be executed within elixir.\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003c!-- \u003ca href=\"https://github.com/lenra-io/template-hello-world-node12\"\u003eView Demo\u003c/a\u003e\n    · --\u003e\n    \u003ca href=\"https://github.com/lenra-io/query-parser/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/lenra-io/query-parser/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\n### Prerequisites\n\nYou need to add this lib into your phoenix app : \n```bash\n    {:query_parser, git: \"https://github.com/lenra-io/query-parser.git\", tag: \"v1.0.0-beta.X\"}\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## Parser\n\n### JSON to AST\n\u003c!-- Add the README link when this pr merge https://github.com/lenra-io/query-parser/pull/6 --\u003e\nWith the parser you can parse a JSON query into an AST tree, for more \ninformation about the format of the JSON query consult this [README](). To parse JSON:\n\n\u003e $\\qquad$ Add the alias:\n```\n  alias QueryParser.AST.Parser\n```\n\n\u003e $\\qquad$ Parse query with function:\n```\n  Parser.from_json(q)\n```\n$\\qquad$ with q the JSON query\n\n### AST to Ecto\nOnce you parse a JSON query into an AST tree you will be able to parse this AST into an Ecto query:\n\n\u003e $\\qquad$ Add the alias:\n```\n  alias QueryParser.AST.EctoParser\n```\n\n\u003e $\\qquad$ Parse query with function:\n```\n  EctoParser.to_ecto(query, env_id, user_data_id)\n```\n$\\qquad$ with:  \n$\\qquad$ $\\qquad$ - query the AST tree  \n$\\qquad$ $\\qquad$ - env_id the environement id  \n$\\qquad$ $\\qquad$ - user_data_id the id of the user's user data \n\nyou can now execute the query with ecto:\n\n```\nRepo.all(ecto_query)\nRepo.one(ecto_query)\n```\nwith ecto_query the query is parsed before, the all function returns a list of all matching results, the one function returns only one element (beware: if there is more than one result the function returns an error), to learn more about the ecto repository  [function](https://hexdocs.pm/ecto/Ecto.Repo.html#query-api)\n\n### Two step together:\n\n\u003e $\\qquad$ Add the alias:\n```\n  alias QueryParser.AST.{EctoParser, Parser}\n```\n\n\u003e $\\qquad$ Parse query with function:\n```\n  Query\n  |\u003e Parser.from_json()\n  |\u003e EctoParser.to_ecto(env_id, user_data_id)\n  |\u003e Repo.all()\n```\n\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please open an issue with the tag \"enhancement\" or \"bug\".\nDon't forget to give the project a star! Thanks again!\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the **AGPL** License. See [LICENSE](./LICENSE) for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nLenra - [@lenra_dev](https://twitter.com/lenra_dev) - contact@lenra.io\n\nProject Link: [https://github.com/lenra-io/query-parser](https://github.com/lenra-io/query-parser)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/lenra-io/query-parser.svg?style=for-the-badge\n[contributors-url]: https://github.com/lenra-io/query-parser/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/lenra-io/query-parser.svg?style=for-the-badge\n[forks-url]: https://github.com/lenra-io/query-parser/network/members\n[stars-shield]: https://img.shields.io/github/stars/lenra-io/query-parser.svg?style=for-the-badge\n[stars-url]: https://github.com/lenra-io/query-parser/stargazers\n[issues-shield]: https://img.shields.io/github/issues/lenra-io/query-parser.svg?style=for-the-badge\n[issues-url]: https://github.com/lenra-io/query-parser/issues\n[license-shield]: https://img.shields.io/github/license/lenra-io/query-parser.svg?style=for-the-badge\n[license-url]: https://github.com/lenra-io/query-parser/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenra-io%2Fquery-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flenra-io%2Fquery-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenra-io%2Fquery-parser/lists"}