0.27.2 • Published 10 days ago

effect-pg v0.27.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 days ago

effect-pg

node-pg wrapper for effect.

Under development

Quickstart

Install the package using

pnpm install effect-pg effect

The following example assumes you have a postgres running. Setup the environment variables as follows.

$ export POSTGRES_USER=<USER>
$ export POSTGRES_PASSWORD=<PASSWORD>
$ export POSTGRES_DATABASE=<PASSWORD>

Optionally, also set POSTGRES_HOST and POSTGRES_NAME. The example below will create a new users table, insert a single row and fetch the row. The persisted row is immediately fetched and logged out.

import { Schema } from "@effect/schema"
import { Effect, pipe } from "effect"
import { PgLayer, PgQuery } from "effect-pg"

const User = Schema.Struct({ name: Schema.String })

const createUsersTable = PgQuery.all(
  "CREATE TABLE IF NOT EXISTS users (name TEXT NOT NULL)"
)
const insertUser = PgQuery.all("INSERT INTO users (name) VALUES ($1)")
const selectUser = PgQuery.one("SELECT * FROM users", User)

pipe(
  createUsersTable(),
  Effect.flatMap(() => insertUser("patrik")),
  Effect.flatMap(() => selectUser()),
  Effect.flatMap((result) => Effect.log(`User: ${JSON.stringify(result)}`)),
  Effect.provide(PgLayer.Client),
  Effect.provide(PgLayer.setConfig()),
  Effect.runPromise
)

Contributing

Local development

Spawn a postgres instance.

$ docker run -d -p 5432:5432 --name test-postgres -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test postgres

Create a .env file.

TEST_POSTGRES_USER=test
TEST_POSTGRES_DATABASE=test
TEST_POSTGRES_PASSWORD=test

Run tests.

pnpm test
0.27.2

10 days ago

0.27.1

20 days ago

0.27.0

1 month ago

0.26.0

1 month ago

0.25.17

1 month ago

0.25.16

2 months ago

0.25.15

2 months ago

0.25.14

2 months ago

0.25.13

2 months ago

0.25.11

2 months ago

0.25.12

2 months ago

0.25.10

2 months ago

0.25.9

2 months ago

0.25.8

2 months ago

0.25.7

2 months ago

0.25.6

2 months ago

0.25.5

2 months ago

0.25.4

2 months ago

0.25.3

3 months ago

0.25.2

3 months ago

0.25.1

3 months ago

0.25.0

3 months ago

0.24.1

4 months ago

0.24.0

4 months ago

0.23.5

4 months ago

0.23.4

4 months ago

0.23.3

4 months ago

0.23.2

4 months ago

0.23.1

4 months ago

0.23.0

5 months ago

0.22.3

5 months ago

0.22.2

5 months ago

0.22.1

5 months ago

0.22.0

5 months ago

0.21.0

6 months ago

0.20.1

6 months ago

0.20.0

6 months ago

0.19.0

6 months ago

0.17.2

7 months ago

0.17.3

6 months ago

0.17.4

6 months ago

0.15.0

7 months ago

0.17.0

7 months ago

0.17.1

7 months ago

0.14.0

7 months ago

0.16.0

7 months ago

0.18.0

6 months ago

0.11.0

8 months ago

0.13.0

7 months ago

0.13.1

7 months ago

0.9.0

8 months ago

0.7.0

9 months ago

0.12.10

8 months ago

0.12.7

8 months ago

0.12.8

8 months ago

0.12.9

8 months ago

0.10.1

8 months ago

0.12.0

8 months ago

0.12.1

8 months ago

0.12.2

8 months ago

0.12.3

8 months ago

0.12.4

8 months ago

0.12.5

8 months ago

0.12.6

8 months ago

0.10.0

8 months ago

0.8.1

8 months ago

0.8.0

9 months ago

0.6.1

9 months ago

0.6.0

9 months ago

0.5.1

9 months ago

0.0.23

11 months ago

0.1.0

10 months ago

0.3.0

10 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.5.0

10 months ago

0.2.3

10 months ago

0.4.0

10 months ago

0.2.2

10 months ago

0.2.4

10 months ago

0.0.20

11 months ago

0.0.21

11 months ago

0.0.22

11 months ago

0.0.19

11 months ago

0.0.15

12 months ago

0.0.16

12 months ago

0.0.17

11 months ago

0.0.18

11 months ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago