airtabledb

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderIndex = iota
	LabelIndex
	AccountIndex
	RepositoryIndex
	MilestoneIndex
	IssueIndex
	NumTables
)

Unfortunately, the order matters here. We must first compute Records which are referenced by other Records...

Variables

View Source
var (
	StateString = map[State]string{
		StateUnknown:   "unknown",
		StateUnchanged: "unchanged",
		StateChanged:   "changed",
		StateNew:       "new",
	}
)
View Source
var (
	TableNameToIndex = map[string]int{
		"provider":   ProviderIndex,
		"label":      LabelIndex,
		"account":    AccountIndex,
		"repository": RepositoryIndex,
		"milestone":  MilestoneIndex,
		"issue":      IssueIndex,
	}
)

Functions

This section is empty.

Types

type AccountRecord

type AccountRecord struct {
	State State `json:"-"` // internal

	airtable.Record // provides ID, CreatedTime
	Fields          struct {
		// base
		Base

		// specific
		URL       string `json:"url"`
		Login     string `json:"login"`
		FullName  string `json:"fullname"`
		Type      string `json:"type"`
		Bio       string `json:"bio"`
		Location  string `json:"location"`
		Company   string `json:"company"`
		Blog      string `json:"blog"`
		Email     string `json:"email"`
		AvatarURL string `json:"avatar-url"`

		// relationships
		Provider []string `json:"provider"`
	} `json:"fields,omitempty"`
}

func (AccountRecord) String

func (r AccountRecord) String() string

type Base

type Base struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created-at"`
	UpdatedAt time.Time `json:"updated-at"`
	Errors    string    `json:"errors"`
}

type DB

type DB struct {
	Tables []Table
}

func NewDB

func NewDB() DB

type IssueRecord

type IssueRecord struct {
	State State `json:"-"` // internal

	airtable.Record // provides ID, CreatedTime
	Fields          struct {
		// base
		Base

		// specific
		URL         string    `json:"url"`
		CompletedAt time.Time `json:"completed-at"`
		Title       string    `json:"title"`
		State       string    `json:"state"`
		Body        string    `json:"body"`
		IsPR        bool      `json:"is-pr"`
		IsLocked    bool      `json:"is-locked"`
		Comments    int       `json:"comments"`
		Upvotes     int       `json:"upvotes"`
		Downvotes   int       `json:"downvotes"`
		IsOrphan    bool      `json:"is-orphan"`
		IsHidden    bool      `json:"is-hidden"`
		Weight      int       `json:"weight"`
		IsEpic      bool      `json:"is-epic"`
		HasEpic     bool      `json:"has-epic"`

		// relationships
		Repository []string `json:"repository"`
		Milestone  []string `json:"milestone"`
		Author     []string `json:"author"`
		Labels     []string `json:"labels"`
		Assignees  []string `json:"assignees"`
	} `json:"fields,omitempty"`
}

func (IssueRecord) String

func (r IssueRecord) String() string

type LabelRecord

type LabelRecord struct {
	State State `json:"-"` // internal

	airtable.Record // provides ID, CreatedTime
	Fields          struct {
		// base
		Base

		// specific
		URL         string `json:"url"`
		Name        string `json:"name"`
		Color       string `json:"color"`
		Description string `json:"description"`
	} `json:"fields,omitempty"`
}

func (LabelRecord) String

func (r LabelRecord) String() string

type MilestoneRecord

type MilestoneRecord struct {
	State State `json:"-"` // internal

	airtable.Record // provides ID, CreatedTime
	Fields          struct {
		// base
		Base

		// specific
		URL         string    `json:"url"`
		Title       string    `json:"title"`
		Description string    `json:"description"`
		ClosedAt    time.Time `json:"closed-at"`
		DueOn       time.Time `json:"due-on"`

		// relationships
		Creator    []string `json:"creator"`
		Repository []string `json:"repository"`
	} `json:"fields,omitempty"`
}

func (MilestoneRecord) String

func (r MilestoneRecord) String() string

type ProviderRecord

type ProviderRecord struct {
	State State `json:"-"` // internal

	airtable.Record // provides ID, CreatedTime
	Fields          struct {
		// base
		Base

		// specific
		URL    string `json:"url"`
		Driver string `json:"driver"`
	} `json:"fields,omitempty"`
}

func (ProviderRecord) String

func (r ProviderRecord) String() string

type Record

type Record interface {
	String() string
}

type RepositoryRecord

type RepositoryRecord struct {
	State State `json:"-"` // internal

	airtable.Record // provides ID, CreatedTime
	Fields          struct {
		// base
		Base

		// specific
		URL         string    `json:"url"`
		Title       string    `json:"title"`
		Description string    `json:"description"`
		Homepage    string    `json:"homepage"`
		PushedAt    time.Time `json:"pushed-at"`
		IsFork      bool      `json:"is-fork"`

		// relationships
		Provider []string `json:"provider"`
		Owner    []string `json:"owner"`
	} `json:"fields,omitempty"`
}

func (RepositoryRecord) String

func (r RepositoryRecord) String() string

type State

type State int
const (
	StateUnknown State = iota
	StateUnchanged
	StateChanged
	StateNew
)

type Table

type Table struct {
	// contains filtered or unexported fields
}

func (Table) Append

func (t Table) Append(record interface{})

Append appends the given record to the table. Will panic if the given record is not of the right type.

func (Table) CopyFields

func (t Table) CopyFields(idx int, srcRecord interface{})

CopyFields copies the 'Fields' struct from srcRecord into the Record at idx in the Tabel t. Will panic necessary fields do not exist.

func (Table) Fetch

func (t Table) Fetch(at airtable.Table) error

Fetch retrieves the airtable table records from at over the network and inserts the records into the table.

func (Table) FindByID

func (t Table) FindByID(id string) string

FindByID searches the table for a record with Fields.ID equal to id. Returns the record's ID if a match is found. Otherwise, returns the empty string.

func (Table) Get

func (t Table) Get(idx int) interface{}

Get returns an interface to the record in the table at idx.

func (Table) GetFieldID

func (t Table) GetFieldID(idx int) string

GetFieldID returns the ID field of the Fields struct of the record at idx in the Table t. Will panic necessary fields do not exist.

func (Table) GetID

func (t Table) GetID(idx int) string

GetID returns the ID field of the record at idx in the Table t.

func (Table) GetPtr

func (t Table) GetPtr(idx int) interface{}

GetPtr returns an interface containing a pointer to the record in the table at index idx.

func (Table) GetState

func (t Table) GetState(idx int) State

func (Table) Len

func (t Table) Len() int

Len returns the number of records in the table.

func (Table) RecordsEqual

func (t Table) RecordsEqual(idx int, b Record) bool

func (Table) SetState

func (t Table) SetState(idx int, state State)

func (Table) StringAt

func (t Table) StringAt(idx int) string

StringAt returns a JSON string of the record in the table at idx.

Jump to

Keyboard shortcuts

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