database

package
v0.0.0-...-0cc5829 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package database keeps the utility functions that converts database type to internal golang type

It also keeps the interface for structs to implement database connection

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetValue

func SetValue(kv key_value.KeyValue, databaseType *sql.ColumnType, raw interface{}) error

SetValue sets the value into kv KeyValue. Before setting, the function converts the value into the desired golang parameter

Types

type Crud

type Crud interface {
	// Update the parameters by int flag. It calls UPDATE command
	Update(interface{}, uint8) error
	// Exist in the database or not. It calls EXIST command
	Exist(interface{}) bool

	// Insert into the database. It calls INSERT command
	Insert(interface{}) error
	// Select selects the single row from the database. It calls SELECT_ROW command
	Select(interface{}) error

	// SelectAll selects the multiple rows from the database. It calls SELECT_ALL without WHERE clause of query.
	//
	// Result is then put to the second argument
	SelectAll(interface{}, interface{}) error

	// SelectAllByCondition returns structs from database to the second argument.
	// The database query should match to the condition.
	//
	// It calls SELECT_ALL with WHERE clause
	SelectAllByCondition(interface{}, key_value.KeyValue, interface{}) error // uses SELECT_ROW
}

Crud interface adds the database CRUD operations to the data struct.

The interface that it accepts is the *remote.ClientSocket from the "github.com/ahmetson/service-lib/remote" package.

Jump to

Keyboard shortcuts

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