Documentation
¶
Index ¶
- func CreateOrOpenDb(name string) *sql.DB
- type AdvancedSqliteApi
- type SqliteApi
- func (sapi *SqliteApi) DeleteAllBy(cond string) error
- func (sapi *SqliteApi) DeleteById(id int) error
- func (sapi *SqliteApi) DropTable() error
- func (sapi *SqliteApi) Insert(cols string, values string) error
- func (sapi *SqliteApi) SelectAll() *sql.Rows
- func (sapi *SqliteApi) SelectById(id int) *sql.Row
- func (sapi *SqliteApi) Sync(cols string) error
- func (sapi *SqliteApi) UpdateById(id int, updates string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateOrOpenDb ¶ added in v0.0.3
Types ¶
type AdvancedSqliteApi ¶ added in v0.0.4
type AdvancedSqliteApi struct {
core.DbApi
Cols map[string]string
FuncOnError func(err error)
IsImportant bool
}
AdvancedSqliteApi just has more automation Cols is a map with all columns example:
map[string]string{
"id": "INTEGER PRIMARY KEY AUTOINCREMENT",
"name": "TEXT"
}
WARNING: do not put ',' or ')' no need in it FuncOnError is a custom function that will be called on error if isImportant is true
func NewAdvancedSqliteApi ¶ added in v0.0.4
func (*AdvancedSqliteApi) DropTable ¶ added in v0.0.5
func (asapi *AdvancedSqliteApi) DropTable() error
func (*AdvancedSqliteApi) InsertWithId ¶ added in v0.0.5
func (asapi *AdvancedSqliteApi) InsertWithId(values []string) error
func (*AdvancedSqliteApi) SelectAll ¶ added in v0.0.5
func (asapi *AdvancedSqliteApi) SelectAll() (*sql.Rows, error)
func (*AdvancedSqliteApi) SelectById ¶ added in v0.0.5
func (asapi *AdvancedSqliteApi) SelectById(id int) *sql.Row
func (*AdvancedSqliteApi) Sync ¶ added in v0.0.4
func (asapi *AdvancedSqliteApi) Sync() error
type SqliteApi ¶
SqliteApi structure is a structure that will interact with sqlite
func (*SqliteApi) DeleteAllBy ¶
it will delete all rows in db with specified condition
example: name="muka" AND id=1
func (*SqliteApi) DeleteById ¶ added in v0.0.2
func (*SqliteApi) Insert ¶
argument 'cols' is a string where you put all columns in which values will be inserted example: name, email argument 'values' is a string with values that will be inserted example: "muka", "cringer@asd.dq"
func (*SqliteApi) SelectAll ¶
if you need to get all rows just use it WARNING: it's returns *sql.Rows that means that other work you need to do on your own
func (*SqliteApi) SelectById ¶ added in v0.0.2
it will select item by id