exchange

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecOption

type ExecOption interface {
	ImporterExecOption
	ExporterExecOption
}

func MaxParamsPerSQL

func MaxParamsPerSQL(v int) ExecOption

type Exporter

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

func NewExporter

func NewExporter(resource interface{}) *Exporter

func (*Exporter) Associations

func (ep *Exporter) Associations(ts ...string) *Exporter

func (*Exporter) Exec

func (ep *Exporter) Exec(db *gorm.DB, w Writer, opts ...ExporterExecOption) error

func (*Exporter) Metas

func (ep *Exporter) Metas(ms ...*Meta) *Exporter

type ExporterExecOption

type ExporterExecOption interface {
	// contains filtered or unexported methods
}

type Importer

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

func NewImporter

func NewImporter(resource interface{}) *Importer

func (*Importer) Associations

func (ip *Importer) Associations(ts ...string) *Importer

func (*Importer) Exec

func (ip *Importer) Exec(db *gorm.DB, r Reader, opts ...ImporterExecOption) error

func (*Importer) Metas

func (ip *Importer) Metas(ms ...*Meta) *Importer

func (*Importer) Validators

func (ip *Importer) Validators(vs ...func(metaValues MetaValues) error) *Importer

type ImporterExecOption

type ImporterExecOption interface {
	// contains filtered or unexported methods
}

type Meta

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

func NewMeta

func NewMeta(field string) *Meta

func (*Meta) Header

func (m *Meta) Header(s string) *Meta

default is field name

func (*Meta) PrimaryKey

func (m *Meta) PrimaryKey(b bool) *Meta

func (*Meta) Setter

func (m *Meta) Setter(f MetaSetter) *Meta

set values to special fields e.g. time.Time, struct, associated records ...

func (*Meta) Valuer

func (m *Meta) Valuer(f MetaValuer) *Meta

format values when exporting

type MetaSetter

type MetaSetter func(record interface{}, value string, metaValues MetaValues) error

type MetaValuer

type MetaValuer func(record interface{}) (string, error)

type MetaValues

type MetaValues interface {
	Get(field string) (val string)
}

type Reader

type Reader interface {
	Header() []string
	ReadRow() ([]string, error)
	Next() bool
	Total() uint
}

func NewCSVReader

func NewCSVReader(rc io.ReadCloser) (Reader, error)

type Writer

type Writer interface {
	WriteHeader([]string) error
	WriteRow([]string) error
	Flush() error
}

func NewCSVWriter

func NewCSVWriter(w io.Writer) (Writer, error)

Directories

Path Synopsis
dig

Jump to

Keyboard shortcuts

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