repository

package
v0.0.0-...-302b2cd Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	gorm.Model

	// An author of the book.
	Author string `json:"author,omitempty"`
	// A book title.
	Title string `json:"title,omitempty"`

	// The shelf Id
	ShelfId int64 `json:"shelf_id,omitempty"`
}

A book resource.

type Repository

type Repository interface {
	AddShelf(s Shelf) (*Shelf, error)
	AddBook(b Book) (*Book, error)
	FindBook(id int64) (Book, error)
	FindShelf(id int64) (Shelf, error)
}

func NewSQLiteRepository

func NewSQLiteRepository() Repository

NewSQLiteRepository return a sequence of repository

type SQLiteRepository

type SQLiteRepository struct {
	*gorm.DB
}

SQLite Repository

func (SQLiteRepository) AddBook

func (r SQLiteRepository) AddBook(body Book) (*Book, error)

func (SQLiteRepository) AddShelf

func (r SQLiteRepository) AddShelf(body Shelf) (*Shelf, error)

func (SQLiteRepository) FindBook

func (r SQLiteRepository) FindBook(id int64) (Book, error)

func (SQLiteRepository) FindShelf

func (r SQLiteRepository) FindShelf(id int64) (Shelf, error)

type Shelf

type Shelf struct {
	gorm.Model
	// Theme the theme of the shelve
	Theme string `json:"theme, omitempty"`
	Books []Book `gorm:"foreignkey:ShelfId"`
}

Jump to

Keyboard shortcuts

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