mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 00:47:33 +00:00
refactor(v2): init events (#7823)
creates events structures for initial projections and read models
This commit is contained in:
@@ -3,6 +3,7 @@ package postgres
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"slices"
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
@@ -38,7 +39,7 @@ func executeQuery(ctx context.Context, tx database.Querier, stmt *database.State
|
||||
}
|
||||
|
||||
err = database.MapRowsToObject(rows, func(scan func(dest ...any) error) error {
|
||||
e := new(eventstore.Event[eventstore.StoragePayload])
|
||||
e := new(eventstore.StorageEvent)
|
||||
|
||||
var payload sql.Null[[]byte]
|
||||
|
||||
@@ -59,7 +60,12 @@ func executeQuery(ctx context.Context, tx database.Querier, stmt *database.State
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.Payload = unmarshalPayload(payload.V)
|
||||
e.Payload = func(ptr any) error {
|
||||
if len(payload.V) == 0 {
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(payload.V, ptr)
|
||||
}
|
||||
eventCount++
|
||||
|
||||
return reducer.Reduce(e)
|
||||
|
Reference in New Issue
Block a user