{"id":27352280,"url":"https://github.com/sukovanej/effect-pg","last_synced_at":"2025-04-12T20:54:55.090Z","repository":{"id":153385452,"uuid":"626114503","full_name":"sukovanej/effect-pg","owner":"sukovanej","description":"node-pg wrapper for effect-ts","archived":true,"fork":false,"pushed_at":"2024-06-04T11:51:10.000Z","size":884,"stargazers_count":13,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T20:54:45.398Z","etag":null,"topics":["effect-ts","fp-ts","node-pg","postgres"],"latest_commit_sha":null,"homepage":"https://sukovanej.github.io/effect-pg/","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/sukovanej.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-10T20:35:59.000Z","updated_at":"2024-06-04T14:56:40.000Z","dependencies_parsed_at":"2023-10-17T04:20:20.396Z","dependency_job_id":"6870a336-5518-493e-b6f7-5cb0eadb138b","html_url":"https://github.com/sukovanej/effect-pg","commit_stats":null,"previous_names":[],"tags_count":98,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukovanej%2Feffect-pg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukovanej%2Feffect-pg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukovanej%2Feffect-pg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sukovanej%2Feffect-pg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sukovanej","download_url":"https://codeload.github.com/sukovanej/effect-pg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631710,"owners_count":21136560,"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":["effect-ts","fp-ts","node-pg","postgres"],"created_at":"2025-04-12T20:54:54.574Z","updated_at":"2025-04-12T20:54:55.083Z","avatar_url":"https://github.com/sukovanej.png","language":"TypeScript","readme":"# effect-pg\n\n[node-pg](https://github.com/brianc/node-postgres) wrapper for\n[effect](https://github.com/Effect-TS).\n\n**Under development**\n\n## Quickstart\n\nInstall the package using\n\n```bash\npnpm install effect-pg effect\n```\n\nThe following example assumes you have a postgres running. Setup the environment\nvariables as follows.\n\n```\n$ export POSTGRES_USER=\u003cUSER\u003e\n$ export POSTGRES_PASSWORD=\u003cPASSWORD\u003e\n$ export POSTGRES_DATABASE=\u003cPASSWORD\u003e\n```\n\nOptionally, also set `POSTGRES_HOST` and `POSTGRES_NAME`. The example below will\ncreate a new `users` table, insert a single row and fetch the row. The persisted\nrow is immediately fetched and logged out.\n\n```typescript\nimport { Schema } from \"@effect/schema\"\nimport { Effect, pipe } from \"effect\"\nimport { PgLayer, PgQuery } from \"effect-pg\"\n\nconst User = Schema.Struct({ name: Schema.String })\n\nconst createUsersTable = PgQuery.all(\n  \"CREATE TABLE IF NOT EXISTS users (name TEXT NOT NULL)\"\n)\nconst insertUser = PgQuery.all(\"INSERT INTO users (name) VALUES ($1)\")\nconst selectUser = PgQuery.one(\"SELECT * FROM users\", User)\n\npipe(\n  createUsersTable(),\n  Effect.flatMap(() =\u003e insertUser(\"patrik\")),\n  Effect.flatMap(() =\u003e selectUser()),\n  Effect.flatMap((result) =\u003e Effect.log(`User: ${JSON.stringify(result)}`)),\n  Effect.provide(PgLayer.Client),\n  Effect.provide(PgLayer.setConfig()),\n  Effect.runPromise\n)\n```\n\n## Contributing\n\n### Local development\n\nSpawn a postgres instance.\n\n```bash\n$ docker run -d -p 5432:5432 --name test-postgres -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test postgres\n```\n\nCreate a `.env` file.\n\n```bash\nTEST_POSTGRES_USER=test\nTEST_POSTGRES_DATABASE=test\nTEST_POSTGRES_PASSWORD=test\n```\n\nRun tests.\n\n```bash\npnpm test\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsukovanej%2Feffect-pg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsukovanej%2Feffect-pg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsukovanej%2Feffect-pg/lists"}