github Effect-TS/effect @effect/sql@0.9.1

latest releases: @effect/typeclass@0.29.14, @effect/vitest@0.13.14, @effect/sql-sqlite-wasm@0.20.5...
2 months ago

Patch Changes

  • #3455 e9da539 Thanks @tim-smart! - add Model module to /sql

    The Model module can be used to create domain schemas with common variants for
    the database and serializing to JSON.

    import { Schema } from "@effect/schema";
    import { Model } from "@effect/sql";
    
    export const GroupId = Schema.Number.pipe(Schema.brand("GroupId"));
    
    export class Group extends Model.Class<Group>("Group")({
      id: Model.Generated(GroupId),
      name: Schema.NonEmptyTrimmedString,
      createdAt: Model.DateTimeInsertFromDate,
      updatedAt: Model.DateTimeUpdateFromDate,
    }) {}
    
    // schema used for selects
    Group;
    
    // schema used for inserts
    Group.insert;
    
    // schema used for updates
    Group.update;
    
    // schema used for json api
    Group.json;
    Group.jsonCreate;
    Group.jsonUpdate;
    
    // you can also turn them into classes
    class GroupJson extends Schema.Class<GroupJson>("GroupJson")(Group.json) {
      get upperName() {
        return this.name.toUpperCase();
      }
    }
  • #3460 4fabf75 Thanks @tim-smart! - support partial objects in sql helpers

  • Updated dependencies [e9da539]:

    • @effect/experimental@0.23.1

Don't miss a new effect release

NewReleases is sending notifications on new releases.