Minor Changes
-
#2693
0724274
Thanks @tim-smart! - make @effect/sql dialect agnosticAll of the client implementations now share the same Context.Tag. This means you can create
services that support multiple SQL flavors.You can now use the
@effect/sql
package to access the client apis:import * as Sql from "@effect/sql"; import { Effect } from "effect"; Effect.gen(function* () { const sql = yield* Sql.client.Client; yield* sql`SELECT * FROM users`; });
If you need a functionality that is specific to a implementation, you can use the tag from the
implementation package:import * as Sqlite from "@effect/sql-sqlite-node"; import { Effect } from "effect"; Effect.gen(function* () { const sql = yield* Sqlite.client.SqliteClient; const dump = yield* sql.export; });
If you need to run a different query depending on the dialect, you can use the
sql.onDialect
api:import * as Sql from "@effect/sql"; import { Effect } from "effect"; Effect.gen(function* () { const sql = yield* Sql.client.Client; yield* sql.onDialect({ sqlite: () => sql`SELECT * FROM sqlite_master`, mysql: () => sql`SHOW TABLES`, mssql: () => sql`SELECT * FROM sys.tables`, pg: () => sql`SELECT * FROM pg_catalog.pg_tables`, }); });
Patch Changes
- #2693
0724274
Thanks @tim-smart! - add .returning helper to insert and update apis