database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database contains the connection pool of SQL. Server should call Initialize before usage. Thanks to Go maintainers, the concurrency support is inbuilt so we do not need to manage connections on our own.

func (*Database) Close

func (db *Database) Close() error

Close is meant to free up resources, to be called when the server wants to shut down.

func (*Database) CreateNote

func (db *Database) CreateNote(n *entity.Note) error

CreateNote will create a new note in the database with a new UUID.

func (*Database) CreateTodo

func (db *Database) CreateTodo(t *entity.Todo) error

CreateTodo will create a new todo in the database with a new UUID.

func (*Database) CreateUser

func (db *Database) CreateUser(u *entity.User) error

CreateUser will create a new user in the database and will have a newly generated UUID.

func (*Database) DeleteTodo

func (db *Database) DeleteTodo(id string) error

DeleteTodo will delete a todo from the database.

func (*Database) DeleteUser

func (db *Database) DeleteUser(id string) error

DeleteUser will delete a user specified by userId.

func (*Database) GetAllNotes

func (db *Database) GetAllNotes(userId string) (*[]entity.Note, error)

GetAllNotes will fetch you a list of notes based on given userId

func (*Database) GetAllPendingTodos

func (db *Database) GetAllPendingTodos(userId string) (*[]entity.Todo, error)

GetAllTodos will return all todos for a given user using userId.

func (*Database) GetNote

func (db *Database) GetNote(id string, userId string) (*[]entity.Note, error)

GetNote will fetch you a note based on id and userId.

func (*Database) GetUser

func (db *Database) GetUser(email string) (*entity.User, error)

GetUser will fetch the first found user from the database.

func (*Database) Initialize

func (db *Database) Initialize(dataSourceName string) error

Initialize will open a database at given dataSourceName.

func (*Database) InsertLog

func (db *Database) InsertLog(l *entity.Log) error

InsertLog will insert a log into the database.

func (*Database) UpdateNote

func (db *Database) UpdateNote(n *entity.Note) error

UpdateNote will update a note in the database.

func (*Database) UpdateTodo

func (db *Database) UpdateTodo(t *entity.Todo) error

UpdateTodo will update a todo in the database.

Jump to

Keyboard shortcuts

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