Effect CommunityEC
Effect Community9mo ago
3 replies
Jonathan Clem

Issue with JSON Serialization of Model in HTTP Handler Response

For some reason, if I have a model like this:

export class Database extends Model.Class<Database>("Database")({
    id: Model.Generated(Schema.Int),
    name: Schema.String,
    schema: Model.JsonFromString(
        Schema.Record({
            key: Schema.String,
            value: Schema.Unknown,
        }),
    ),
    createdAt: TimestampInsert,
    updatedAt: TimestampUpdate,
}) {}


And it's returned from an HTTP handler whose success type is Database, the return value gets messed with—I get a JSON string back for schema but if I just set the success type Schema.Any I get the object as expected. It also does weird things with my timestamps.
Was this page helpful?