github Effect-TS/effect @effect/sql-sqlite-bun@0.2.0

latest releases: @effect/typeclass@0.24.40, @effect/printer@0.33.40, @effect/printer-ansi@0.33.40...
2 months ago

Minor Changes

  • #2693 0724274 Thanks @tim-smart! - make @effect/sql dialect agnostic

    All 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

Don't miss a new effect release

NewReleases is sending notifications on new releases.