adsa-cms: github.com/mmanjoura/adsa-cms/exchange Index | Files | Directories

package exchange

import "github.com/mmanjoura/adsa-cms/exchange"

Index

Package Files

container.go exchange.go meta.go progress.go

type Cell Uses

type Cell struct {
    Header string
    Value  interface{}
    Error  error
}

Cell is a data cell, which including its data and error that happened when importing/exporting data

type Config Uses

type Config struct {
    // PrimaryField that used as primary field when searching resource from database
    PrimaryField string
    // Permission defined permission
    Permission *roles.Permission
    // WithoutHeader no header in the data file
    WithoutHeader bool
}

Config is exchange resource config

type Container Uses

type Container interface {
    NewReader(*Resource, *qor.Context) (Rows, error)
    NewWriter(*Resource, *qor.Context) (Writer, error)
}

Container is an interface, any exporting/importing backends needs to implement this

type Meta Uses

type Meta struct {
    resource.Meta
    Name       string
    Header     string
    Valuer     func(interface{}, *qor.Context) interface{}
    Setter     func(resource interface{}, metaValue *resource.MetaValue, context *qor.Context)
    Permission *roles.Permission
    // contains filtered or unexported fields
}

Meta defines importable/exportable fields

func (*Meta) GetMetas Uses

func (meta *Meta) GetMetas() []resource.Metaor

GetMetas get defined sub metas

func (*Meta) GetResource Uses

func (meta *Meta) GetResource() resource.Resourcer

GetResource get its resource

type Progress Uses

type Progress struct {
    Current uint
    Total   uint
    Value   interface{}
    Cells   []Cell
}

Progress defined importing/exporting progress

type Resource Uses

type Resource struct {
    resource.Resource
    Config *Config
    // contains filtered or unexported fields
}

Resource defined an exchange resource, which includes importing/exporting fields definitions

func NewResource Uses

func NewResource(value interface{}, config ...Config) *Resource

NewResource new exchange Resource

func (*Resource) Export Uses

func (res *Resource) Export(container Container, context *qor.Context, callbacks ...func(Progress) error) error

Export used export data from a exchange Resource

product.Export(csv.New("products.csv"), context)

func (*Resource) GetMeta Uses

func (res *Resource) GetMeta(name string) *Meta

GetMeta get defined Meta from exchange Resource

func (*Resource) GetMetas Uses

func (res *Resource) GetMetas([]string) []resource.Metaor

GetMetas get all defined Metas from exchange Resource

func (*Resource) Import Uses

func (res *Resource) Import(container Container, context *qor.Context, callbacks ...func(Progress) error) error

Import used to import data into a exchange Resource

product.Import(csv.New("products.csv"), context)

func (*Resource) Meta Uses

func (res *Resource) Meta(meta *Meta) *Meta

Meta define exporting/importing meta for exchange Resource

type Rows Uses

type Rows interface {
    Header() []string
    ReadRow() (*resource.MetaValues, error)
    Next() bool
    Total() uint
}

Rows is an interface, backends need to implement this in order to read data from it

type Writer Uses

type Writer interface {
    WriteHeader() error
    WriteRow(interface{}) (*resource.MetaValues, error)
    Flush()
}

Writer is an interface, backends need to implement this in order to write data

Directories

PathSynopsis
backends/csv

Package exchange imports 7 packages (graph) and is imported by 2 packages. Updated 2017-06-20. Refresh now. Tools for package owners.