qlx

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

qlx

A database driver extension for https://modernc.org/ql

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToQlType

func ToQlType(t reflect.Type, dbTag string) (string, error)

func ToTableName

func ToTableName(s string) string

Types

type BaseModel

type BaseModel struct {
	Type      reflect.Type
	Dsn       string //file path,like : ./app.db or [empty]
	Pool      *ql.DB
	TableName string
	// contains filtered or unexported fields
}

func NewBaseModel

func NewBaseModel(dsn string, data interface{}) (*BaseModel, error)

* NewBaseModel creates a *BaseModel. 1.dsn: file path or empty string. File path like "./app.db"; Empty string for memory database. 2.data: Struct{}

func NewBaseModelWithCreated

func NewBaseModelWithCreated(dsn string, data interface{}) (*BaseModel, bool, error)

func (*BaseModel) Clear

func (b *BaseModel) Clear() error

func (*BaseModel) CountWhere

func (b *BaseModel) CountWhere(where string, args ...interface{}) (int64, error)

func (*BaseModel) Delete

func (b *BaseModel) Delete(id int64) error

func (*BaseModel) DeleteWhere

func (b *BaseModel) DeleteWhere(where string, args ...interface{}) error

func (*BaseModel) Exists

func (b *BaseModel) Exists(id int64) (bool, error)

func (*BaseModel) ExistsWhere

func (b *BaseModel) ExistsWhere(where string, args ...interface{}) (bool, error)

func (*BaseModel) Find

func (b *BaseModel) Find(id int64) (interface{}, error)

func (*BaseModel) FindWhere

func (b *BaseModel) FindWhere(where string, args ...interface{}) (interface{}, error)

func (*BaseModel) GetCreateTableSQL

func (b *BaseModel) GetCreateTableSQL() string

func (*BaseModel) GetIndexes

func (b *BaseModel) GetIndexes() ([]Index, error)

func (*BaseModel) GetInsertSQL

func (b *BaseModel) GetInsertSQL() ([]int, string)

func (*BaseModel) GetSelectSQL

func (b *BaseModel) GetSelectSQL() string

func (*BaseModel) Insert

func (b *BaseModel) Insert(v interface{}) (interface{}, error)

func (*BaseModel) InsertAll

func (b *BaseModel) InsertAll(vs interface{}) error

func (*BaseModel) QueryWhere

func (b *BaseModel) QueryWhere(where string, args ...interface{}) (interface{}, error)

func (*BaseModel) Truncate

func (b *BaseModel) Truncate() error

func (*BaseModel) UpdateSet

func (b *BaseModel) UpdateSet(sets string, where string, args ...interface{}) error

type Column

type Column struct {
	TableName string `ql:"TableName"`
	Ordinal   int64  `ql:"ordinal"`
	Name      string `ql:"name"`
	Type      string `ql:"type"`
}

func DescTable

func DescTable(pool *ql.DB, tableName string) ([]Column, error)

type Index

type Index struct {
	TableName  string `ql:"TableName"`
	ColumnName string `ql:"ColumnName"`
	Name       string `ql:"Name"`
	IsUnique   bool   `ql:"isUnique"`
}

func (Index) ToIndexName

func (i Index) ToIndexName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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