OperatorEventDocument.cs
1 namespace GUNRPG.Infrastructure.Persistence; 2 3 /// <summary> 4 /// LiteDB document for storing operator events. 5 /// This is the persistence model - the event objects from Core are mapped to/from this. 6 /// </summary> 7 public sealed class OperatorEventDocument 8 { 9 /// <summary> 10 /// Auto-incrementing primary key for LiteDB. 11 /// </summary> 12 public int Id { get; set; } 13 14 /// <summary> 15 /// The operator this event belongs to. 16 /// Indexed for fast queries. 17 /// </summary> 18 public Guid OperatorId { get; set; } 19 20 /// <summary> 21 /// Sequential number within the operator's event stream. 22 /// Indexed for ordering. 23 /// </summary> 24 public long SequenceNumber { get; set; } 25 26 /// <summary> 27 /// Event type discriminator (e.g., "XpGained", "WoundsTreated"). 28 /// </summary> 29 public string EventType { get; set; } = string.Empty; 30 31 /// <summary> 32 /// JSON-serialized payload. 33 /// </summary> 34 public string Payload { get; set; } = string.Empty; 35 36 /// <summary> 37 /// Hash of the previous event in the chain. 38 /// </summary> 39 public string PreviousHash { get; set; } = string.Empty; 40 41 /// <summary> 42 /// Hash of this event. 43 /// </summary> 44 public string Hash { get; set; } = string.Empty; 45 46 /// <summary> 47 /// When this event was created. 48 /// </summary> 49 public DateTimeOffset Timestamp { get; set; } 50 51 /// <summary> 52 /// The account that owns this operator. 53 /// Populated on the genesis event (SequenceNumber == 0) when the operator is created. 54 /// Not part of the event hash chain — stored as ownership metadata only. 55 /// </summary> 56 public Guid? AccountId { get; set; } 57 }