Documentation ¶
Index ¶
- type ArrayPredicate
- type Constraint
- type Database
- func (db *Database) CreateTable(scheme interface{}, constraint ...*Constraint) *Table
- func (db *Database) FindTable(str interface{}) *Table
- func (db *Database) ListTables() []*Table
- func (m *Database) Manager() *SheetManager
- func (m *Database) Sheets() []*sheets.Sheet
- func (m *Database) Spreadsheet() *sheets.Spreadsheet
- type Predicate
- type SheetManager
- type Table
- func (table *Table) Delete(deleteThis ArrayPredicate) []int64
- func (table *Table) Drop() bool
- func (table *Table) Name() string
- func (table *Table) Select(rows int64) ([][]interface{}, *TableScheme)
- func (table *Table) SelectAndFilter(filters map[int]Predicate) ([][]interface{}, *TableScheme)
- func (table *Table) UpsertIf(values []interface{}, appendData bool, conditions ...map[int]Predicate) bool
- type TableScheme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayPredicate ¶
type ArrayPredicate func([]interface{}) bool
ArrayPredicate Check if the given interface fits the condition
type Constraint ¶
type Constraint struct {
// contains filtered or unexported fields
}
Constraint Describes table constraints. Only unique columns constraint supported.
func NewConstraint ¶
func NewConstraint() *Constraint
NewConstraint Returns pointer to new empty constraint.
func (*Constraint) SetUniqueColumns ¶
func (c *Constraint) SetUniqueColumns(columns ...string) *Constraint
SetUniqueColumns Sets unique columns to table
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database Wrapper for *sheets.Spreadsheet
func (*Database) CreateTable ¶
func (db *Database) CreateTable(scheme interface{}, constraint ...*Constraint) *Table
CreateTable Creates a new sheet(a.k.a. table) with `tableName` on the given Spreadsheet(a.k.a. database). Case handling: database == nil: return nil database != nil: log as creating, and return the created sheet with true
func (*Database) FindTable ¶
FindTable Gets an existing sheet(a.k.a. table) with `tableName` on the given Spreadsheet(a.k.a. database) If exists, returns the existed one If not existing, returns nil
func (*Database) ListTables ¶
ListTables Gets an existing sheets(a.k.a. table) in the given Spreadsheet(a.k.a. database). If exists, returns the existings If not existing, returns nil
func (*Database) Spreadsheet ¶
func (m *Database) Spreadsheet() *sheets.Spreadsheet
Spreadsheet Proxy
type Predicate ¶
type Predicate func(interface{}) bool
Predicate Check if the given interface fits the condition
type SheetManager ¶
type SheetManager struct {
// contains filtered or unexported fields
}
SheetManager Manage OAuth2 token lifecycle
func NewSheetManager ¶
func NewSheetManager(jsonPath string) *SheetManager
NewSheetManager Create new SheetManager api count: 1
func (*SheetManager) CreateDatabase ¶
func (m *SheetManager) CreateDatabase(title string) *Database
CreateDatabase creates a new database with the given database_file_`title`. Be careful, 'database_file_' tag is on the start of the title. api count: 1
func (*SheetManager) DropDatabase ¶
func (m *SheetManager) DropDatabase(title string) bool
DropDatabase deletes a database with the given database_file_`title`, if exists. If not existing, or failed to delete, it will log and return false. Be careful, 'database_file_' tag is implicitly on the start of the title finding for.
func (*SheetManager) FindDatabase ¶
func (m *SheetManager) FindDatabase(title string) *Database
FindDatabase gets a new database with the given database_file_`title`, if exists. If not existing, it will return nil. Be careful, 'database_file_' tag is on the start of the title finding for. api count: 1
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table Wrapper of the table(spreadsheet.sheet)
func (*Table) Delete ¶
func (table *Table) Delete(deleteThis ArrayPredicate) []int64
Delete Deletes and returns deleted rows deleteThis: input - array of row values returns: array of rows starting from 0
func (*Table) Drop ¶
Drop Drops the table(a.k.a. sheet). If exists, deletes and returns true If not existing, logs and returns false Always update
func (*Table) Select ¶
func (table *Table) Select(rows int64) ([][]interface{}, *TableScheme)
Select Selects all the rows from the table
func (*Table) SelectAndFilter ¶
func (table *Table) SelectAndFilter(filters map[int]Predicate) ([][]interface{}, *TableScheme)
SelectAndFilter Select rows satisfying filter filters.key: int, column index filters.value: Predicate, whether to select or not
type TableScheme ¶
type TableScheme struct { Name string Columns []string ColumnMap map[string]int64 Types []reflect.Kind Rows int64 Constraints *Constraint }
TableScheme Metadata of the table