github Effect-TS/effect @effect/sql-sqlite-node@0.9.0

latest releases: @effect/sql-sqlite-bun@0.12.7, @effect/typeclass@0.27.3, @effect/sql-sqlite-react-native@0.14.6...
one month ago

Minor Changes

  • #3457 a07990d Thanks @IMax153! - Add support for executing raw SQL queries with the underlying SQL client.

    This is primarily useful when the SQL client returns special results for certain
    query types.

    For example, because MySQL does not support the RETURNING clause, the mysql2
    client will return a ResultSetHeader
    for INSERT, UPDATE, DELETE, and TRUNCATE operations.

    To gain access to the raw results of a query, you can use the .raw property on
    the Statement:

    import * as Effect from "effect/Effect";
    import * as SqlClient from "@effect/sql/SqlClient";
    import * as MysqlClient from "@effect/sql/MysqlClient";
    
    const DatabaseLive = MysqlClient.layer({
      database: Config.succeed("database"),
      username: Config.succeed("root"),
      password: Config.succeed(Redacted.make("password")),
    });
    
    const program = Effect.gen(function* () {
      const sql = yield* SqlClient.SqlClient;
    
      const result = yield* sql`INSERT INTO usernames VALUES ("Bob")`.raw;
    
      console.log(result);
      /**
       * ResultSetHeader {
       *   fieldCount: 0,
       *   affectedRows: 1,
       *   insertId: 0,
       *   info: '',
       *   serverStatus: 2,
       *   warningStatus: 0,
       *   changedRows: 0
       * }
       */
    });
    
    program.pipe(Effect.provide(DatabaseLive), Effect.runPromise);

Patch Changes

Don't miss a new effect release

NewReleases is sending notifications on new releases.