db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package db manages all the interactions related to the database.

Copyright © 2021 Alan Rojas alandavidrl11@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package db manages all the interactions related to the database.

Copyright © 2021 Alan Rojas alandavidrl11@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BucketExists

func BucketExists(name string) bool

BucketExists returns whether a Bucket exists

func CreateCategory

func CreateCategory(name string) (int, error)

CreateCategory creates a nested bucket within the main database bucket

func CreateTask

func CreateTask(category, payload string) (int, error)

CreateTask adds done task to it's proper category

func Init

func Init(dbPath string)

Init exposes database initialization to external clients

Types

type Category

type Category struct {
	Key string `json:"category"`
}

Category is the representation of a nested bucket that holds tasks

func ListCategories

func ListCategories() ([]Category, error)

ListCategories returns a list of all the buckets in database

type JSONCategory

type JSONCategory struct {
	Category string `json:"category"`
	Tasks    []Task `json:"tasks"`
}

JSONCategory holds a slice of tasks as the only key. It is also the representation of a JSON schema of categories and their tasks.

func ExportData

func ExportData() ([]JSONCategory, error)

ExportData returns JSON data from all database data

type Task

type Task struct {
	Key     int    `json:"id"`
	Value   string `json:"description"`
	Created string `json:"created"`
}

Task is the representation of a task that is done by the being time

func ListTasks

func ListTasks(category string) ([]Task, error)

ListTasks returns all the done tasks related to a category

Jump to

Keyboard shortcuts

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