sqlite

package
v0.0.0-...-e0e25f9 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSchema

func CreateSchema(ctx context.Context, schema *pkg.Schema, db *sqlx.DB) error

CreateSchema creates the schema in the database. It generates all the SQL queries to CREATE the tables and indexes and runs it inside a transaction.

func GenerateSQLiteCreateTable

func GenerateSQLiteCreateTable(schema *pkg.Schema) (map[string][]string, error)

func GenerateSQLiteDeleteObject

func GenerateSQLiteDeleteObject(schema *pkg.Schema) (map[string]string, error)

func GenerateSQLiteGetObjectMainTable

func GenerateSQLiteGetObjectMainTable(schema *pkg.Schema) (string, error)

GenerateSQLiteGetObjectMainTable generates SQLite query for getting the object with id from table.

func GenerateSQLiteGetObjectSecondaryTable

func GenerateSQLiteGetObjectSecondaryTable(schema *pkg.Schema, name string) (string, error)

func GenerateSQLiteListObjectsMainTable

func GenerateSQLiteListObjectsMainTable(schema *pkg.Schema, limit, offset int) (string, error)

func GenerateSQLiteListObjectsSecondaryTable

func GenerateSQLiteListObjectsSecondaryTable(schema *pkg.Schema, name string, ids []int64) (
	string,
	error,
)

func GenerateSQLiteUpdateObject

func GenerateSQLiteUpdateObject(schema *pkg.Schema) (map[string]string, error)

func GetObject

func GetObject(
	ctx context.Context,
	db *sqlx.DB,
	schema *pkg.Schema,
	id int64,
) (map[string]interface{}, error)

func InsertData

func InsertData(ctx context.Context, db *sqlx.DB, schema *pkg.Schema, data map[string]interface{}) (int64, error)

Types

type PaginationRequest

type PaginationRequest struct {
	Offset int
	Limit  int
}

type PaginationResponse

type PaginationResponse struct {
	Total  int
	Data   []map[string]interface{}
	Offset int
}

func ListObjects

func ListObjects(
	ctx context.Context,
	db *sqlx.DB,
	schema *pkg.Schema,
	paginationRequest *PaginationRequest,
) (*PaginationResponse, error)

type QueryData

type QueryData struct {
	Fields    []pkg.Field
	TableName string
	IdField   string
	Limit     int
	Offset    int
}

type TableData

type TableData struct {
	TableName string
	Fields    []pkg.Field
}

Jump to

Keyboard shortcuts

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