{"id":18221669,"url":"https://github.com/kamirus/purescript-selda","last_synced_at":"2025-04-03T02:30:43.758Z","repository":{"id":47146631,"uuid":"155055824","full_name":"Kamirus/purescript-selda","owner":"Kamirus","description":"A type-safe, high-level SQL library for PureScript","archived":false,"fork":false,"pushed_at":"2023-03-02T17:29:50.000Z","size":484,"stargazers_count":89,"open_issues_count":31,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T04:26:24.066Z","etag":null,"topics":["edsl","nested-queries","postgresql","purescript","purescript-selda","query","query-language","row-polymorphism","sql","sql-library","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"PureScript","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/Kamirus.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}},"created_at":"2018-10-28T09:48:04.000Z","updated_at":"2024-12-21T20:37:49.000Z","dependencies_parsed_at":"2024-01-14T15:56:15.732Z","dependency_job_id":null,"html_url":"https://github.com/Kamirus/purescript-selda","commit_stats":{"total_commits":180,"total_committers":4,"mean_commits":45.0,"dds":0.02777777777777779,"last_synced_commit":"a81f47f9054e9ea893d5ef79586be70068462249"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kamirus%2Fpurescript-selda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kamirus%2Fpurescript-selda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kamirus%2Fpurescript-selda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kamirus%2Fpurescript-selda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kamirus","download_url":"https://codeload.github.com/Kamirus/purescript-selda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246925187,"owners_count":20855850,"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":["edsl","nested-queries","postgresql","purescript","purescript-selda","query","query-language","row-polymorphism","sql","sql-library","sqlite3"],"created_at":"2024-11-03T22:03:47.970Z","updated_at":"2025-04-03T02:30:43.355Z","avatar_url":"https://github.com/Kamirus.png","language":"PureScript","readme":"# purescript-selda\n\n[![CI](https://github.com/Kamirus/purescript-selda/workflows/CI/badge.svg)](https://github.com/Kamirus/purescript-selda/actions)\n\n## About\n\n**purescript-selda** is an **SQL library** (*eDSL*) which allows a user to write **type-safe queries**.\n- Generated SQL is guaranteed to be correct by the type system.\n- It supports **arbitrarily nested queries** with capabilities of **filtering**, **joins** and **aggregation**.\n- We used **standard monadic abstraction** which supports writing queries in a linear, natural style.\n- Our main target is **PostgreSQL** though in the upcoming release (already on master) we add **SQLite3** support (with ability to support other db backends).\n\n\n## Example Query\n\nTo declare a type for a SQL table (already created in the db)\nwe write the following table definition:\n```purescript\npeople ∷ Table (id ∷ Int, name ∷ String, age ∷ Maybe Int)\npeople = Table { name: \"people\" }\n```\n\nOnce we've defined the tables, we can write queries, e.g.\n\n```purescript\nselectFrom people \\{ id, name, age } → do\n  { balance } ← leftJoin bankAccounts \\b → id .== b.personId\n  restrict $ id .\u003e lit 1\n  pure { id, balance }\n```\n\nGenerated SQL for the above query:\n```sql\nSELECT people_0.id AS id, bank_accounts_1.balance AS balance\nFROM people people_0\nLEFT JOIN bank_accounts bank_accounts_1 ON ((people_0.id = bank_accounts_1.personId))\nWHERE ((people_0.id \u003e 1))\n```\n\nFor a more gentle introduction and more examples please refer to the [Step-by-Step Guide](guide/SimpleE2E.md).\n\n## More Help\n\n**If you have any questions please don't hesitate to ask**.\n\u003cbr\u003eI'll be happy to help and provide any guidance if necessary.\n\u003cbr\u003eOpen an issue or hit me up directly (either on [slack](https://functionalprogramming.slack.com/), [forum](https://discourse.purescript.org/) or directly via email).\n\n## Install\n\nInstall [postgresql-client's dependencies](https://github.com/rightfold/purescript-postgresql-client#install)\n\u003e npm install pg decimal.js\n\n## Info\n\n- [**Introductory Guide**](guide/SimpleE2E.md): End-to-End example: how to setup, write queries, use aggregation, deal with type errors and execute queries and inserts.\n- [**Advanced Guide**](guide/Custom.md): Custom Types and Expressions (`litPG`, `Any`, `EForeign`, custom PG functions), more flexible table definitions (`Source`, db schemas, set-returning functions) - unsafe escape hatches\n- **Test Suite**: For information about features, examples, usage, etc. refer to the test suite: [`Test.Common`](test/Common.purs), [`Test.PG`](test/PG.purs), [`Test.SQLite3`](test/SQLite3.purs). To run the tests, `docker-compose up -d` helps to prepare postgres database.\n- **Documentation**: [Pursuit docs](https://pursuit.purescript.org/packages/purescript-selda/)\n- [**My thesis**](./selda.pdf)\n\n## Credits\n\nSupported by [Lambda Terms](https://github.com/lambdaterms/)\n\nInspired by [selda](https://github.com/valderman/selda)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamirus%2Fpurescript-selda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamirus%2Fpurescript-selda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamirus%2Fpurescript-selda/lists"}