db

package
v0.0.0-...-e022c58 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ID   = "id"
	Name = "Databases"
)

Variables

This section is empty.

Functions

func GetID

func GetID(r map[string]interface{}) string

func GetInt

func GetInt(r map[string]interface{}, key string) int

func GetString

func GetString(r map[string]interface{}, key string) string

Types

type DB

type DB interface {
	// SaveDatabase create database if not exists.
	SaveDatabase(ctx context.Context, name string) (id string, err error)
	// SaveTable create or update table.
	SaveTable(ctx context.Context, database string, table Table) (string, error)
	// ListTables list table by database.
	ListTables(ctx context.Context, database string) []string
	// DropTable should return err if database or table not exists.
	DropTable(ctx context.Context, database, table string) error

	// Create table record. id is generated.
	Create(ctx context.Context, database, table string, record map[string]interface{}) (id string, err error)
	// Read table records.
	Read(ctx context.Context, database, table string, ss []SearchCmd) []map[string]interface{}
	// Update record by id.
	Update(ctx context.Context, database, table, id string, record map[string]interface{}) error
	// Delete record by id.
	Delete(ctx context.Context, database, table, id string) error
}

func NewDB

func NewDB(appId string, appSecret string) (DB, error)

type Database

type Database struct {
	Name   string
	Tables []Table
}

type Field

type Field struct {
	Name string
	Type FieldType
}

type FieldManager

type FieldManager interface {
	ListFields(ctx context.Context, appToken string, tableId string) ([]*larkBitable.AppTableField, error)
	CreateField(ctx context.Context, appToken string, tableId string, body *larkBitable.AppTableField) (string, error)
	UpdateField(ctx context.Context, appToken string, tableId string, body *larkBitable.AppTableField) error
	DeleteField(ctx context.Context, appToken string, tableId, fieldId string) error
}

type FieldType

type FieldType int
const (
	String      FieldType = 1
	Int         FieldType = 2
	Radio       FieldType = 3
	MultiSelect FieldType = 4
	Date        FieldType = 5
	People      FieldType = 11
)

type SearchCmd

type SearchCmd struct {
	Key, Operator string
	Val           interface{}
}

type Table

type Table struct {
	Name   string
	Fields []Field
}

Jump to

Keyboard shortcuts

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