todo

package
v0.0.0-...-404caef Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const AggregateType = "todo"
View Source
const TypeCreated = AggregateType + ".created.v1"
View Source
const TypeTaskAdded = AggregateType + ".task-added.v1" // or "task.added.v1" this semantic is up to you

Variables

This section is empty.

Functions

func AddTask

func AddTask(ctx context.Context, p *AddTaskParams, existingTodo *eventsourcing.Aggregate[*Todo], metadata map[string]any) error

func Create

func Create(ctx context.Context, cmd *CreateParams, metadata map[string]any) (*eventsourcing.Aggregate[*Todo], error)

Types

type AddTaskParams

type AddTaskParams struct {
	Title       string     `json:"name"`
	Description string     `json:"description"`
	DueDate     *time.Time `json:"due_date"`
}

type CreateParams

type CreateParams struct {
	Name string `json:"name"`
}

type Todo

type Todo struct {
	Name      string     `json:"name"`
	Tasks     []task     `json:"tasks"`
	CreatedAt *time.Time `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

func (*Todo) AddTask

func (t *Todo) AddTask(title, description string, dueDate *time.Time, status status)

func (*Todo) StorageName

func (t *Todo) StorageName() string

StorageName returns the name of the table or collection where the events are stored. If Todo do not implement this method, the default name used will be the AggregateType. By convention in some database server like Postgres, the table name should be in plural. This is why implementing this method is made possible here to override the table name.

func (*Todo) Type

func (t *Todo) Type() string

func (*Todo) Zero

func (t *Todo) Zero() eventsourcing.AggregateState

Jump to

Keyboard shortcuts

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