model

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

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

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 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
	// PrintModeCSV print data in csv format
	PrintModeCSV
	// 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 records.

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) Print added in v0.0.5

func (t *Table) Print(out *os.File, 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