db

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialSubjectDoc

type CredentialSubjectDoc struct {
	FirstName   string `bson:"first_name"`
	LastName    string `bson:"last_name"`
	DateOfBirth string `bson:"date_of_birth"` // Format: YYYY-MM-DD
	Section     int64  `bson:"section"`
	Index       int64  `bson:"index"`
}

CredentialSubjectDoc represents a person with their token status list reference

type CredentialSubjectsColl

type CredentialSubjectsColl struct {
	Service *Service
	Coll    *mongo.Collection
	// contains filtered or unexported fields
}

CredentialSubjectsColl is the collection for credential subjects (person info linked to Token Status List entries)

func NewCredentialSubjectsColl

func NewCredentialSubjectsColl(ctx context.Context, collName string, service *Service, log *logger.Log) (*CredentialSubjectsColl, error)

NewCredentialSubjectsColl creates a new credential subjects collection

func (*CredentialSubjectsColl) Add

Add adds a new credential subject to the collection

func (*CredentialSubjectsColl) Search

func (c *CredentialSubjectsColl) Search(ctx context.Context, firstName, lastName, dateOfBirth string) ([]*CredentialSubjectDoc, error)

Search searches for credential subjects by name and/or date of birth All parameters are optional - empty strings are ignored

type Service

type Service struct {
	MongoClient *mongo.Client

	// Token Status List collections (MongoDB)
	TokenStatusListColl     *TokenStatusListColl
	TokenStatusListMetadata *TokenStatusListMetadataColl
	CredentialSubjects      *CredentialSubjectsColl
	// contains filtered or unexported fields
}

Service is the database service

func New

func New(ctx context.Context, cfg *model.Cfg, tracer *trace.Tracer, log *logger.Log) (*Service, error)

New creates a new database service

func (*Service) Close

func (s *Service) Close(ctx context.Context) error

Close closes the database connections

type TokenStatusListColl

type TokenStatusListColl struct {
	Service *Service
	Coll    *mongo.Collection
	// contains filtered or unexported fields
}

TokenStatusListColl is the collection for status list

func NewTokenStatusListColl

func NewTokenStatusListColl(ctx context.Context, collName string, service *Service, log *logger.Log) (*TokenStatusListColl, error)

NewTokenStatusListColl creates a new Token Status List coll

func (*TokenStatusListColl) Add

func (c *TokenStatusListColl) Add(ctx context.Context, section int64, status uint8) (int64, error)

Add adds a new status to the status list collection, return index of the added status or an error

func (*TokenStatusListColl) CountDocs

func (c *TokenStatusListColl) CountDocs(ctx context.Context, filter bson.M) (int64, error)

CountDocs counts documents matching the filter

func (*TokenStatusListColl) CreateNewSection

func (c *TokenStatusListColl) CreateNewSection(ctx context.Context, section int64, sectionSize int64) error

CreateNewSection creates a new section with decoy entries.

func (*TokenStatusListColl) FindOne

func (c *TokenStatusListColl) FindOne(ctx context.Context, section, index int64) (*TokenStatusListDoc, error)

FindOne finds a single status entry by section and index

func (*TokenStatusListColl) GetAllStatusesForSection

func (c *TokenStatusListColl) GetAllStatusesForSection(ctx context.Context, section int64) ([]uint8, error)

GetAllStatusesForSection retrieves all status entries for a given section, ordered by index. Returns a slice of status values (uint8) suitable for encoding into a Status List Token.

func (*TokenStatusListColl) InitializeIfEmpty

func (c *TokenStatusListColl) InitializeIfEmpty(ctx context.Context) error

InitializeIfEmpty checks if the collection is empty and initializes it with sample data

func (*TokenStatusListColl) UpdateStatus

func (c *TokenStatusListColl) UpdateStatus(ctx context.Context, section int64, index int64, status uint8) error

UpdateStatus updates the status of an existing entry at the given section and index.

type TokenStatusListDoc

type TokenStatusListDoc struct {
	Index   int64 `bson:"index"`
	Status  uint8 `bson:"status"`
	Decoy   bool  `bson:"decoy"`
	Section int64 `bson:"section"`
}

TokenStatusListDoc represents a document in the Token Status List document

type TokenStatusListMetadataColl

type TokenStatusListMetadataColl struct {
	Service *Service
	Coll    *mongo.Collection
	// contains filtered or unexported fields
}

TokenStatusListMetadataColl is the collection for status list metadata

func NewTokenStatusListMetadataColl

func NewTokenStatusListMetadataColl(ctx context.Context, collName string, service *Service, log *logger.Log) (*TokenStatusListMetadataColl, error)

NewTokenStatusListMetadataColl creates a new StatusListMetadataColl

func (*TokenStatusListMetadataColl) GetAllSections

func (c *TokenStatusListMetadataColl) GetAllSections(ctx context.Context) ([]int64, error)

GetAllSections returns all section IDs that have been created. Used for Status List Aggregation (Section 9.3).

func (*TokenStatusListMetadataColl) GetCurrentSection

func (c *TokenStatusListMetadataColl) GetCurrentSection(ctx context.Context) (int64, error)

GetCurrentSection returns the current section number

func (*TokenStatusListMetadataColl) UpdateCurrentSection

func (c *TokenStatusListMetadataColl) UpdateCurrentSection(ctx context.Context, newSection int64) error

UpdateCurrentSection updates the current section and adds it to the sections list

type TokenStatusListMetadataDoc

type TokenStatusListMetadataDoc struct {
	CurrentSection int64   `bson:"current_section"`
	Sections       []int64 `bson:"sections"`
}

TokenStatusListMetadataDoc represents a document in the status list metadata collection

type TokenStatusListMetadataStore

type TokenStatusListMetadataStore interface {
	GetCurrentSection(ctx context.Context) (int64, error)
	UpdateCurrentSection(ctx context.Context, newSection int64) error
	GetAllSections(ctx context.Context) ([]int64, error)
}

TokenStatusListMetadataStore defines the interface for token status list metadata operations

type TokenStatusListStore

type TokenStatusListStore interface {
	CountDocs(ctx context.Context, filter bson.M) (int64, error)
	CreateNewSection(ctx context.Context, section int64, sectionSize int64) error
	Add(ctx context.Context, section int64, status uint8) (int64, error)
	UpdateStatus(ctx context.Context, section int64, index int64, status uint8) error
	GetAllStatusesForSection(ctx context.Context, section int64) ([]uint8, error)
	InitializeIfEmpty(ctx context.Context) error
	FindOne(ctx context.Context, section, index int64) (*TokenStatusListDoc, error)
}

TokenStatusListStore defines the interface for token status list operations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL