Documentation
¶
Index ¶
- type BoltGoalStore
- func (s *BoltGoalStore) CreateGoal(goal *models.Goal) error
- func (s *BoltGoalStore) DeleteGoal(id string) error
- func (s *BoltGoalStore) GetGoal(id string) (*models.Goal, error)
- func (s *BoltGoalStore) GetGoalByObjective(objective string) (*models.Goal, error)
- func (s *BoltGoalStore) GetGoalsByPlannerId(plannerId string) ([]*models.Goal, error)
- func (s *BoltGoalStore) ListGoals() ([]*models.Goal, error)
- func (s *BoltGoalStore) UpdateGoal(goal *models.Goal) error
- type BoltPlanStore
- func (s *BoltPlanStore) CreatePlan(plan *models.Plan) error
- func (s *BoltPlanStore) DeletePlan(id string) error
- func (s *BoltPlanStore) GetPlan(id string) (*models.Plan, error)
- func (s *BoltPlanStore) GetPlanByName(name string) (*models.Plan, error)
- func (s *BoltPlanStore) GetPlansByGoal(id string) ([]*models.Plan, error)
- func (s *BoltPlanStore) ListPlans() ([]*models.Plan, error)
- func (s *BoltPlanStore) UpdatePlan(plan *models.Plan) error
- type BoltPlannerStore
- func (s *BoltPlannerStore) CreatePlanner(planner *models.Planner) error
- func (s *BoltPlannerStore) DeletePlanner(id string) error
- func (s *BoltPlannerStore) GetPlanner(id string) (*models.Planner, error)
- func (s *BoltPlannerStore) GetPlannerByOwner(id string) ([]*models.Planner, error)
- func (s *BoltPlannerStore) GetPlannerByTitle(title string) (*models.Planner, error)
- func (s *BoltPlannerStore) ListPlanners() ([]*models.Planner, error)
- func (s *BoltPlannerStore) UpdatePlanner(planner *models.Planner) error
- type BoltTaskStore
- func (s *BoltTaskStore) CreateTask(task *models.Task) error
- func (s *BoltTaskStore) DeleteTask(id string) error
- func (s *BoltTaskStore) GetTask(id string) (*models.Task, error)
- func (s *BoltTaskStore) GetTaskByOwner(owner string) ([]*models.Task, error)
- func (s *BoltTaskStore) GetTaskByTitle(title string) (*models.Task, error)
- func (s *BoltTaskStore) ListTasks() ([]*models.Task, error)
- func (s *BoltTaskStore) UpdateTask(id string, task *models.Task) error
- type BoltVersionStore
- func (s *BoltVersionStore) CreateVersion(v *models.Version) error
- func (s *BoltVersionStore) GetImage(goalId *models.EntityID, versionNo *models.VersionInfo) (*models.Snapshot, error)
- func (s *BoltVersionStore) GetPreviousVersion(id string) (*models.Version, error)
- func (s *BoltVersionStore) GetVersion(id string) (*models.Version, error)
- func (s *BoltVersionStore) ListVersions() ([]*models.Version, error)
- func (s *BoltVersionStore) UpdateVersion(id string, v *models.Version) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoltGoalStore ¶
type BoltGoalStore struct {
// contains filtered or unexported fields
}
BoltGoalStore represents a goal store implementation that uses BoltDB as the underlying database. CreateGoal creates a new goal in the store.
func NewInMemoryGoalStore ¶
func NewInMemoryGoalStore(db *storm.DB) *BoltGoalStore
NewInMemoryGoalStore is a function that returns a new instance of BoltGoalStore initialized with the given storm.DB. It takes a pointer to a storm.DB as a parameter. It returns a pointer to BoltGoalStore.
func (*BoltGoalStore) CreateGoal ¶
func (s *BoltGoalStore) CreateGoal(goal *models.Goal) error
CreateGoal creates a new goal in the BoltGoalStore. It takes a Goal object as a parameter and saves it to the database. The Goal object should have the following fields: - Id : string - Objective : string - Plans : []Plan - GoalStatus : string - GoalCreatedAt : time.Time - GoalUpdatedAt : time.Time - Deadline : time.Time - PlannerID : string Returns an error if the save operation fails.
func (*BoltGoalStore) DeleteGoal ¶
func (s *BoltGoalStore) DeleteGoal(id string) error
DeleteGoal takes an ID string and deletes the goal with that ID from the database. It creates a new instance of models.Goal with the given ID, sets it as the ID of the goal to be deleted, and then calls the DeleteStruct method of the s.db (storm.DB) object to delete the goal from the database. An error is returned if the delete operation fails.
func (*BoltGoalStore) GetGoal ¶
func (s *BoltGoalStore) GetGoal(id string) (*models.Goal, error)
GetGoal takes an id string and returns the goal with that id from the database. If the goal is not found, it returns nil and an error. If an error occurs during the database query, it returns nil and the error.
func (*BoltGoalStore) GetGoalByObjective ¶
func (s *BoltGoalStore) GetGoalByObjective(objective string) (*models.Goal, error)
GetGoalByObjective takes an objective string and retrieves the corresponding goal from the database. If the goal is found, it is returned along with nil error. If the goal is not found or an error occurs during the retrieval, nil goal and the error are returned.
func (*BoltGoalStore) GetGoalsByPlannerId ¶
func (s *BoltGoalStore) GetGoalsByPlannerId(plannerId string) ([]*models.Goal, error)
GetGoalsByPlannerId takes a plannerId string as input and retrieves all goals associated with the specified plannerId from the database. It returns a slice of Goal objects and an error. If the database retrieval fails, it returns nil and the error. If the retrieval is successful, it returns the slice of Goal objects and nil error.
func (*BoltGoalStore) ListGoals ¶
func (s *BoltGoalStore) ListGoals() ([]*models.Goal, error)
ListGoals retrieves all goals from the database and returns them as a slice of Goal objects.
func (*BoltGoalStore) UpdateGoal ¶
func (s *BoltGoalStore) UpdateGoal(goal *models.Goal) error
UpdateGoal takes a Goal object and updates it in the database. An error is returned if the update operation fails.
type BoltPlanStore ¶
type BoltPlanStore struct {
// contains filtered or unexported fields
}
BoltPlanStore represents a store for managing plans using BoltDB.
func NewInMemoryPlanStore ¶
func NewInMemoryPlanStore(db *storm.DB) *BoltPlanStore
NewInMemoryPlanStore creates a new instance of BoltPlanStore by initializing it with the provided DB instance.
func (*BoltPlanStore) CreatePlan ¶
func (s *BoltPlanStore) CreatePlan(plan *models.Plan) error
CreatePlan inserts a new plan into the BoltDB database. It takes a pointer to a models.Plan as an argument and returns an error. The function calls the Save method of the underlying BoltDB connection, passing the plan as the argument to save it as a new record in the database.
func (*BoltPlanStore) DeletePlan ¶
func (s *BoltPlanStore) DeletePlan(id string) error
DeletePlan deletes a plan from the BoltPlanStore. It takes in an id string as a parameter. It creates a new Plan with the given id. It then calls the DeleteStruct method on the BoltPlanStore's database connection, passing in the Plan. The DeleteStruct method returns an error if there was an issue deleting the Plan. If the deletion was successful, nil is returned. Example usage: err := store.DeletePlan("123")
if err != nil { fmt.Println("Error deleting plan:", err) } else { fmt.Println("Plan deleted successfully") }
func (*BoltPlanStore) GetPlan ¶
func (s *BoltPlanStore) GetPlan(id string) (*models.Plan, error)
GetPlan retrieves a plan from the BoltPlanStore based on the specified ID. It takes a string parameter "id" representing the ID of the plan to be retrieved. Returns a pointer to a models.Plan object and an error. If there was an issue retrieving the plan from the database, an error is returned.
Example usage:
plan, err := store.GetPlan("123") if err != nil { log.Println("Failed to get plan:", err) } fmt.Println(plan)
Note: This method is part of the BoltPlanStore struct that provides methods for managing plans. The BoltPlanStore struct uses the storm.DB instance for database operations. To access other methods in the BoltPlanStore, create an instance of the struct and call the desired method.
See also: BoltPlanStore, models.Plan
func (*BoltPlanStore) GetPlanByName ¶
func (s *BoltPlanStore) GetPlanByName(name string) (*models.Plan, error)
GetPlanByName retrieves a plan by its name. It takes a string parameter 'name' representing the plan name. It returns a pointer to a Plan object and an error. If there was an issue while retrieving the plan from the database, an error is returned. Otherwise, the plan is returned.
func (*BoltPlanStore) GetPlansByGoal ¶
func (s *BoltPlanStore) GetPlansByGoal(id string) ([]*models.Plan, error)
GetPlansByGoal retrieves plans associated with a specific goal ID. It takes a string parameter 'id' representing the goal ID. It returns a slice of pointers to Plan objects and an error. If there was an issue while retrieving the plans from the database, an error is returned. Otherwise, the slice of plans
func (*BoltPlanStore) ListPlans ¶
func (s *BoltPlanStore) ListPlans() ([]*models.Plan, error)
ListPlans retrieves all plans from the BoltPlanStore. It returns a slice of pointers to Plan objects representing the plans, and an error if there was an issue while retrieving the plans from the database.
func (*BoltPlanStore) UpdatePlan ¶
func (s *BoltPlanStore) UpdatePlan(plan *models.Plan) error
UpdatePlan updates an existing plan in the BoltPlanStore. It takes a pointer to a Plan object representing the plan to be updated. It returns an error if there was an issue while updating the plan in the database.
type BoltPlannerStore ¶
type BoltPlannerStore struct {
// contains filtered or unexported fields
}
BoltPlannerStore represents a store for managing planners using a BoltDB database.
func NewInMemoryPlannerStore ¶
func NewInMemoryPlannerStore(db *storm.DB) *BoltPlannerStore
NewInMemoryPlannerStore returns a new instance of the BoltPlannerStore type with the provided storm.DB instance as its database.
func (*BoltPlannerStore) CreatePlanner ¶
func (s *BoltPlannerStore) CreatePlanner(planner *models.Planner) error
CreatePlanner creates a new planner in the BoltPlannerStore. It takes a pointer to a models.Planner object as its argument and returns an error. It saves the planner object to the underlying BoltDB database using the db.Save() method. If the save operation fails, it returns an error.
func (*BoltPlannerStore) DeletePlanner ¶
func (s *BoltPlannerStore) DeletePlanner(id string) error
DeletePlanner deletes a planner from the BoltPlannerStore. It takes an ID as a parameter and returns an error.
func (*BoltPlannerStore) GetPlanner ¶
func (s *BoltPlannerStore) GetPlanner(id string) (*models.Planner, error)
GetPlanner retrieves a planner by its ID from the BoltPlannerStore.
Parameters: - id: the ID of the planner to retrieve.
Returns: - *models.Planner: the retrieved planner. - error: an error if the planner cannot be retrieved.
func (*BoltPlannerStore) GetPlannerByOwner ¶
func (s *BoltPlannerStore) GetPlannerByOwner(id string) ([]*models.Planner, error)
GetPlannerByOwner returns a list of planners owned by the specified user ID. It queries the database to find all planners that have a "UserId" field matching the provided ID. If an error occurs during the query, it returns nil and the error. Otherwise, it returns the list of found planners and nil for the error.
func (*BoltPlannerStore) GetPlannerByTitle ¶
func (s *BoltPlannerStore) GetPlannerByTitle(title string) (*models.Planner, error)
GetPlannerByTitle retrieves a planner with the specified title from the BoltPlannerStore.
func (*BoltPlannerStore) ListPlanners ¶
func (s *BoltPlannerStore) ListPlanners() ([]*models.Planner, error)
ListPlanners returns a list of all planners in the BoltPlannerStore database. Each planner is of type *models.Planner. If there is an error during the retrieval process, an error is returned along with the empty list of planners.
func (*BoltPlannerStore) UpdatePlanner ¶
func (s *BoltPlannerStore) UpdatePlanner(planner *models.Planner) error
UpdatePlanner updates the details of a planner in the Bolt DB. It takes a *models.Planner as input and returns an error if the update operation fails.
type BoltTaskStore ¶
type BoltTaskStore struct {
// contains filtered or unexported fields
}
BoltTaskStore is a type that represents a task store backed by a BoltDB database.
func NewInMemoryTaskStore ¶
func NewInMemoryTaskStore(db *storm.DB) *BoltTaskStore
NewInMemoryTaskStore creates a new in-memory task store with the given storm.DB instance. It returns a pointer to the BoltTaskStore. Usage example:
db, err := storm.Open("test.db", storm.BoltOptions(0600, nil)) if err != nil { log.Fatalf("Failed to open database: %v", err) } defer func(db *storm.DB) { err := db.CloseS() if err != nil { log.Fatalf("Failed to close database: %v", err) } }(db) // Create a new in-memory store inMemoryStore := NewInMemoryTaskStore(db) // create a new taskMake service taskService := services.NewTaskService(inMemoryStore) // Create a taskMake handler taskHandler := handle.NewTaskControl(taskService) log.Printf("Task handler: %v", taskHandler) // Create a new taskMake taskMake, err := taskHandler.CreateTask(handle.CreateTaskRequest{ Title: "Task 1", Description: "Task 1 description", Owner: "Me", }) if err != nil { log.Fatalf("Failed to create taskMake: %v", err) } log.Printf("Task created: %s", taskMake.ID) // Get the taskMake taskGet, err := taskHandler.GetTask(&handle.GetTaskRequest{ID: taskMake.ID}) if err != nil { log.Fatalf("Failed to get taskMake: %v", err) } log.Printf("Task retrieved: %s", taskGet.Title) log.Printf("Description: %s", taskGet.Description) log.Printf("Owner: %s", taskGet.Owner) log.Printf("Started: %t", taskGet.Started)
func (*BoltTaskStore) CreateTask ¶
func (s *BoltTaskStore) CreateTask(task *models.Task) error
CreateTask method creates a new task in the BoltTaskStore. It takes a pointer to a models.Task object as a parameter. Returns an error if the operation fails.
func (*BoltTaskStore) DeleteTask ¶
func (s *BoltTaskStore) DeleteTask(id string) error
DeleteTask deletes a task from the BoltTaskStore. It takes the ID of the task as a parameter and returns an error if any occurred during the deletion process. The function first creates a new Task object with the provided ID, then calls the DeleteStruct method of the BoltDB instance to remove the task from the database.
Example usage: err := myTaskStore.DeleteTask("task-123")
if err != nil { fmt.Println("Error deleting task:", err) }
func (*BoltTaskStore) GetTask ¶
func (s *BoltTaskStore) GetTask(id string) (*models.Task, error)
GetTask retrieves a task from the BoltTaskStore based on the given ID. It returns the task and an error if any occurred. If the task with the given ID is not found, it returns nil and an error.
func (*BoltTaskStore) GetTaskByOwner ¶
func (s *BoltTaskStore) GetTaskByOwner(owner string) ([]*models.Task, error)
GetTaskByOwner retrieves a task from the BoltTaskStore based on the given owner.
func (*BoltTaskStore) GetTaskByTitle ¶
func (s *BoltTaskStore) GetTaskByTitle(title string) (*models.Task, error)
GetTaskByTitle retrieves a task from the BoltTaskStore based on the given title.
func (*BoltTaskStore) ListTasks ¶
func (s *BoltTaskStore) ListTasks() ([]*models.Task, error)
ListTasks retrieves a list of tasks from the BoltTaskStore.
func (*BoltTaskStore) UpdateTask ¶
func (s *BoltTaskStore) UpdateTask(id string, task *models.Task) error
UpdateTask updates a task with the specified ID. It takes the ID string and the task struct as input parameters. It assigns the provided ID to the task's ID field and then updates the task in the BoltDB using the db.Update method. Returns an error if there was an issue while updating the task in the BoltDB.
type BoltVersionStore ¶
type BoltVersionStore struct {
// contains filtered or unexported fields
}
func NewInMemoryVersionStore ¶
func NewInMemoryVersionStore(db *storm.DB) *BoltVersionStore
func (*BoltVersionStore) CreateVersion ¶
func (s *BoltVersionStore) CreateVersion(v *models.Version) error
func (*BoltVersionStore) GetImage ¶
func (s *BoltVersionStore) GetImage(goalId *models.EntityID, versionNo *models.VersionInfo) (*models.Snapshot, error)
func (*BoltVersionStore) GetPreviousVersion ¶
func (s *BoltVersionStore) GetPreviousVersion(id string) (*models.Version, error)
func (*BoltVersionStore) GetVersion ¶
func (s *BoltVersionStore) GetVersion(id string) (*models.Version, error)
func (*BoltVersionStore) ListVersions ¶
func (s *BoltVersionStore) ListVersions() ([]*models.Version, error)
func (*BoltVersionStore) UpdateVersion ¶
func (s *BoltVersionStore) UpdateVersion(id string, v *models.Version) error