model

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package model defines Data Transfer Object (Entity, Value Object)

Package model defines Data Transfer Object (Entity, Value Object)

Package model defines Data Transfer Object (Entity, Value Object)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSV

type CSV struct {
	Name    string
	Header  Header
	Records []Record
}

CSV is csv data with header.

func (*CSV) IsHeaderEmpty

func (c *CSV) IsHeaderEmpty() bool

IsHeaderEmpty return wherther header is empty or not

func (*CSV) SetHeader

func (c *CSV) SetHeader(header Header)

SetHeader set header column.

func (*CSV) SetRecord

func (c *CSV) SetRecord(record Record)

SetRecord set csv record.

func (*CSV) ToTable

func (c *CSV) ToTable() *Table

ToTable convert CSV to Table.

type Header []string

Header is CSV/TSV/Table header.

type Histories added in v0.0.5

type Histories []*History

Histories is sqly history all record.

func (Histories) ToStringList added in v0.2.0

func (h Histories) ToStringList() []string

ToStringList convert history to string list.

func (Histories) ToTable added in v0.0.5

func (h Histories) ToTable() *Table

ToTable convert History to Table.

type History added in v0.0.5

type History struct {
	// ID is history id. 1 is oldest
	ID int
	// Request is sqly history record that is user input from sqly prompt
	Request string
}

History is sqly history record.

type JSON added in v0.3.0

type JSON struct {
	// Name is json file name
	Name string
	// JSON is key and value
	JSON []map[string]interface{}
}

JSON is json data with indefinite keys

func (*JSON) ToTable added in v0.3.0

func (j *JSON) ToTable() *Table

ToTable convert JSON to Table.

type LTSV added in v0.5.0

type LTSV struct {
	Name    string
	Label   Label
	Records []Record
}

LTSV is Labeled Tab-separated Values data with label.

func (*LTSV) IsLabelEmpty added in v0.5.0

func (l *LTSV) IsLabelEmpty() bool

IsLabelEmpty return wherther label is empty or not

func (*LTSV) SetLabel added in v0.5.0

func (l *LTSV) SetLabel(label Label)

SetLabel set label column.

func (*LTSV) SetRecord added in v0.5.0

func (l *LTSV) SetRecord(record Record)

SetRecord set tsv record.

func (*LTSV) ToTable added in v0.5.0

func (l *LTSV) ToTable() *Table

ToTable convert TSV to Table.

type Label added in v0.5.0

type Label []string

Label is LTSV label.

type PrintMode added in v0.0.10

type PrintMode uint

PrintMode is enum to specify output method

const (
	// PrintModeTable print data in table format
	PrintModeTable PrintMode = iota
	// PrintModeMarkdownTable print data in markdown table format
	PrintModeMarkdownTable
	// PrintModeCSV print data in csv format
	PrintModeCSV
	// PrintModeTSV print data in tsv format
	PrintModeTSV
	// PrintModeLTSV print data in ltsv format
	PrintModeLTSV
	// PrintModeJSON print data in json format
	PrintModeJSON
)

func (PrintMode) String added in v0.3.0

func (p PrintMode) String() string

type Record

type Record []string

Record is CSV/TSV/Table records.

type TSV added in v0.4.0

type TSV struct {
	Name    string
	Header  Header
	Records []Record
}

TSV is tsv data with header.

func (*TSV) IsHeaderEmpty added in v0.4.0

func (t *TSV) IsHeaderEmpty() bool

IsHeaderEmpty return wherther header is empty or not

func (*TSV) SetHeader added in v0.4.0

func (t *TSV) SetHeader(header Header)

SetHeader set header column.

func (*TSV) SetRecord added in v0.4.0

func (t *TSV) SetRecord(record Record)

SetRecord set tsv record.

func (*TSV) ToTable added in v0.4.0

func (t *TSV) ToTable() *Table

ToTable convert TSV to Table.

type Table

type Table struct {
	Name    string
	Header  Header
	Records []Record
}

Table is DB table.

func (*Table) IsEmptyHeader

func (t *Table) IsEmptyHeader() bool

IsEmptyHeader return wherther table header is empty or not

func (*Table) IsEmptyName

func (t *Table) IsEmptyName() bool

IsEmptyName return wherther table name is empty or not

func (*Table) IsEmptyRecords

func (t *Table) IsEmptyRecords() bool

IsEmptyRecords return wherther table records is empty or not

func (*Table) IsSameHeaderColumnName added in v0.3.1

func (t *Table) IsSameHeaderColumnName() bool

IsSameHeaderColumnName return whether the table has a header column with the same name

func (*Table) Print added in v0.0.5

func (t *Table) Print(out io.Writer, mode PrintMode)

Print print all record with header

func (*Table) Valid

func (t *Table) Valid() error

Valid check the contents of a Table.

Jump to

Keyboard shortcuts

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