datastore

package
v0.0.0-...-e7a43b6 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenSysDatabase

func OpenSysDatabase(driver, dataSource string) error

OpenSysDatabase Return an open database connection

func UpdateDatabase

func UpdateDatabase() error

UpdateDatabase creates or updates tables by using DDL

Types

type DB

type DB struct {
	*sql.DB
}

DB struct holding database implementation for datastore

var Db *DB

Db pointer to database hander

func (*DB) CreateMyType

func (db *DB) CreateMyType(myType MyType) (int, error)

CreateMyType Inserts a new register

func (*DB) CreateMyTypeTable

func (db *DB) CreateMyTypeTable() error

CreateMyTypeTable creates the database table

func (*DB) DeleteMyType

func (db *DB) DeleteMyType(id int) error

DeleteMyType deletes a register

func (*DB) FindMyType

func (db *DB) FindMyType(name string) (MyType, error)

FindMyType searches for a specific register

func (*DB) GetMyType

func (db *DB) GetMyType(id int) (MyType, error)

GetMyType returns a specific register

func (*DB) ListMyTypes

func (db *DB) ListMyTypes() ([]MyType, error)

ListMyTypes returns all the registers of the table

func (*DB) UpdateMyType

func (db *DB) UpdateMyType(id int, myType MyType) error

UpdateMyType updates a register

type Datastore

type Datastore interface {
	CreateMyTypeTable() error
	ListMyTypes() ([]MyType, error)
	GetMyType(id int) (MyType, error)
	FindMyType(name string) (MyType, error)
	CreateMyType(myType MyType) (int, error)
	UpdateMyType(id int, myType MyType)
	DeleteMyType(id int) error
}

Datastore interface for different data storages

type MyType

type MyType struct {
	ID          int
	Name        string
	Description string
	SubTypes    bool
}

MyType test type to generate skeletom code

Jump to

Keyboard shortcuts

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