gosheet

package module
v0.0.0-...-66f22f2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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

func (db *Database) FindTable(str interface{}) *Table

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

func (db *Database) ListTables() []*Table

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) Manager

func (m *Database) Manager() *SheetManager

Manager Proxy

func (*Database) Sheets

func (m *Database) Sheets() []*sheets.Sheet

Sheets Proxy

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

func (table *Table) Drop() bool

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) Name

func (table *Table) Name() string

Name name of the table

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

func (*Table) UpsertIf

func (table *Table) UpsertIf(values []interface{}, appendData bool, conditions ...map[int]Predicate) bool

UpsertIf Upserts given `values`. Returns true if success. condition.key: column index

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

Jump to

Keyboard shortcuts

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