guestbook

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: MIT Imports: 7 Imported by: 0

README

justguestbook ver. 1.3.0

A library implementing simple guestbook with replies.

Documentation

Index

Constants

View Source
const DateFormat = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	ID          int64     `json:"entry_id"`
	Created     time.Time `json:"created"`
	Name        string    `json:"name"`
	Website     string    `json:"website,omitempty"`
	HideWebsite bool      `json:"hide_website,omitempty"`
	Message     string    `json:"message"`
	Reply       *Reply    `json:"reply,omitempty"`
}

func NewEntry

func NewEntry(name, message, website string, hideWebsite bool) (*Entry, error)

type Guestbook

type Guestbook interface {
	Entries(page, pageSize int64) ([]*Entry, error)
	Count() (int64, error)
	NewEntry(entry *Entry) error
	EditEntry(entry *Entry) error
	DeleteEntry(entryID int64) error
	NewReply(reply *Reply) error
	EditReply(reply *Reply) error
	DeleteReply(entryID int64) error
	Close() error
}

func NewSQLiteDB

func NewSQLiteDB(filePath string) (Guestbook, error)

type Reply

type Reply struct {
	ID      int64     `json:"-"`
	Created time.Time `json:"created,omitempty"`
	Message string    `json:"message"`
}

func NewReply

func NewReply(entryID int64, message string) (*Reply, error)

type SQLiteDatabase

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

func (*SQLiteDatabase) Close

func (d *SQLiteDatabase) Close() error

func (*SQLiteDatabase) Count

func (d *SQLiteDatabase) Count() (count int64, err error)

Count returns how much entries are in an `entry` table.

func (*SQLiteDatabase) DeleteEntry

func (d *SQLiteDatabase) DeleteEntry(entryID int64) error

func (*SQLiteDatabase) DeleteReply

func (d *SQLiteDatabase) DeleteReply(entryID int64) error

func (*SQLiteDatabase) EditEntry

func (d *SQLiteDatabase) EditEntry(entry *Entry) error

func (*SQLiteDatabase) EditReply

func (d *SQLiteDatabase) EditReply(reply *Reply) error

func (*SQLiteDatabase) Entries

func (d *SQLiteDatabase) Entries(page, pageSize int64) (entries []*Entry, err error)

func (*SQLiteDatabase) NewEntry

func (d *SQLiteDatabase) NewEntry(entry *Entry) error

NewEntry inserts a passed Entry struct and fills its ID field if successful.

func (*SQLiteDatabase) NewReply

func (d *SQLiteDatabase) NewReply(reply *Reply) error

Jump to

Keyboard shortcuts

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