{
  "services": [
    {
      "name": "Orders",
      "description": "Replace with a sentence about the service, or remove this line.",
      "assemblies": ["Contoso.Orders.Domain.dll"],
      "connectionString": "Orders",
      "domain": {
        "streams":    [ { "type": "Contoso.Orders.Domain.OrderId" }, { "type": "Contoso.Orders.Domain.LoyaltyAccountId" } ],
        "events":     [ { "namespace": "Contoso.Orders.Domain.Events" } ],
        "aggregates": [
          { "type": "Contoso.Orders.Domain.Order", "id": "Contoso.Orders.Domain.OrderId" },
          { "type": "Contoso.Orders.Domain.LoyaltyBalance", "id": "Contoso.Orders.Domain.LoyaltyAccountId" }
        ],
        "naming":     { "events": "snake-case", "aggregates": "lower-case" },
        "fold":       { "methods": ["Apply"], "version": "Version",
                        "wrapper": { "type": "JasperFx.Events.Event",
                                     "facts": { "Version": "sequence", "Sequence": "id", "Timestamp": "written", "StreamKey": "streamId" } } },
        "serializer": { "kind": "system-text-json" },
        "hidden":     ["Id", "Version"]
      },
      "store": {
        "events": {
          "table": "public.mt_events", "where": "is_archived = false",
          "streamId": "stream_id", "sequence": "version", "type": "type", "payload": "data",
          "written": "timestamp", "id": "seq_id"
        },
        "snapshots": [
          {
            "sql": "SELECT d.id, d.data, d.mt_last_modified, s.created, s.version AS seq FROM public.mt_doc_order d JOIN public.mt_streams s ON s.id = d.id",
            "typeName": "order", "streamId": "id", "id": "id",
            "version": "(data->>'Version')::bigint", "appliedUpTo": "seq", "payload": "data",
            "created": "created", "updated": "mt_last_modified"
          },
          {
            "sql": "SELECT d.id, d.data, d.mt_last_modified, s.created, s.version AS seq FROM public.mt_doc_loyaltybalance d JOIN public.mt_streams s ON s.id = d.id",
            "typeName": "loyaltybalance", "streamId": "id", "id": "id",
            "version": "(data->>'Version')::bigint", "appliedUpTo": "seq", "payload": "data",
            "created": "created", "updated": "mt_last_modified"
          }
        ]
      }
    }
  ]
}
