database

package
v0.0.0-...-1632d91 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 8 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 interface {
	GetPosts(int, int) ([]common.Post, error)
	GetPost(post_id int) (common.Post, error)
	AddPost(title string, excerpt string, content string) (int, error)
	ChangePost(id int, title string, excerpt string, content string) error
	DeletePost(id int) (int, error)
	AddPage(title string, content string, link string) (int, error)
	GetPage(link string) (common.Page, error)

	AddPermalink(permalink common.Permalink) (int, error)
	GetPermalinks() ([]common.Permalink, error)
}

type SqlDatabase

type SqlDatabase struct {
	Address    string
	Port       int
	User       string
	Connection *sql.DB
}

func MakeMysqlConnection

func MakeMysqlConnection(user string, password string, address string, port int, database string) (SqlDatabase, error)

func MakeSqliteConnection

func MakeSqliteConnection(databaseFile string) (SqlDatabase, error)

func (SqlDatabase) AddPage

func (db SqlDatabase) AddPage(title string, content string, link string) (int, error)
func (db SqlDatabase) AddPermalink(permalink common.Permalink) (int, error)

func (SqlDatabase) AddPost

func (db SqlDatabase) AddPost(title string, excerpt string, content string) (int, error)

/ This function adds a post to the database

func (SqlDatabase) ChangePost

func (db SqlDatabase) ChangePost(id int, title string, excerpt string, content string) error

/ This function changes a post based on the values / provided. Note that empty strings will mean that / the value will not be updated.

func (SqlDatabase) DeletePost

func (db SqlDatabase) DeletePost(id int) (int, error)

/ This function changes a post based on the values / provided. Note that empty strings will mean that / the value will not be updated.

func (SqlDatabase) GetPage

func (db SqlDatabase) GetPage(link string) (common.Page, error)
func (db SqlDatabase) GetPermalinks() ([]common.Permalink, error)

func (SqlDatabase) GetPost

func (db SqlDatabase) GetPost(post_id int) (post common.Post, err error)

/ This function gets a post from the database / with the given ID.

func (SqlDatabase) GetPosts

func (db SqlDatabase) GetPosts(limit int, offset int) (all_posts []common.Post, err error)

/ This function gets all the posts from the current / database connection.

Jump to

Keyboard shortcuts

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