Documentation
¶
Overview ¶
Package models defines the persisted document shapes for admin-api.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureIndexes ¶
EnsureIndexes creates the indexes admin-api relies on: a MongoDB TTL index on expires_at that physically removes expired documents, and a compound index on (scope_type, scope_value) to keep the scoped-query path fast. Safe to call on every startup - CreateOne is idempotent for an identical index definition.
Types ¶
type BannerMessage ¶
type BannerMessage struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
ScopeType ScopeType `bson:"scope_type" json:"scope_type"`
ScopeValue string `bson:"scope_value" json:"scope_value"`
Severity Severity `bson:"severity" json:"severity"`
Message string `bson:"message" json:"message"`
StartsAt *time.Time `bson:"starts_at,omitempty" json:"starts_at,omitempty"`
ExpiresAt time.Time `bson:"expires_at" json:"expires_at"`
CreatedBy string `bson:"created_by" json:"created_by"`
CreatedAt time.Time `bson:"created_at" json:"created_at"`
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"`
}
BannerMessage is the MongoDB document for a platform-wide, service-scoped, or page-scoped admin banner.
func (*BannerMessage) Validate ¶
func (b *BannerMessage) Validate() error
Validate checks that the banner satisfies the invariants required by the spec: a known scope type, a scope value present exactly when the scope requires one, a known severity, a non-empty message, and a required expires_at.