record

package
v0.0.0-...-c5ebb49 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2016 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package record provides records for the charlatan package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVRecord

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

CSVRecord is a CSV record, i.e. a line from a CSV file

If created with a header its fields can be retrieved with their column name. In any case, one can use a "$N" field name, where N is the column index, starting at 0.

All values are retrieved as strings, and the special field "*" can be used to get a string representation of the record values.

func NewCSVRecord

func NewCSVRecord(record []string) *CSVRecord

NewCSVRecord returns a new CSVRecord

func NewCSVRecordWithHeader

func NewCSVRecordWithHeader(record []string, header []string) *CSVRecord

NewCSVRecordWithHeader returns a new CSVRecord with the given header

func (*CSVRecord) AtIndex

func (r *CSVRecord) AtIndex(index int) (*ch.Const, error)

AtIndex gets the value at the given index

func (*CSVRecord) ColumnNameIndex

func (r *CSVRecord) ColumnNameIndex(name string) int

ColumnNameIndex searches the index of the column name in this record’s header. If it doesn’t have a header or if the column wasn’t found, the method returns -1. The column name match is case-sensitive, the first matching one is used.

func (*CSVRecord) Find

func (r *CSVRecord) Find(field *ch.Field) (*ch.Const, error)

Find implements the charlatan.Record interface

type JSONRecord

type JSONRecord struct {
	SoftMatching bool
	// contains filtered or unexported fields
}

JSONRecord is a record for JSON objects.

It supports the special field "*", as in "SELECT * FROM x WHERE y", which returns the JSON as-is, except that the keys order is not garanteed.

If the SoftMatching attribute is set to true, non-existing fields are returned as null contants instead of failing with an error.

func NewJSONRecordFromDecoder

func NewJSONRecordFromDecoder(dec *json.Decoder) (*JSONRecord, error)

NewJSONRecordFromDecoder creates a new JSONRecord from a JSON decoder

func (*JSONRecord) Find

func (r *JSONRecord) Find(field *ch.Field) (*ch.Const, error)

Find implements the charlatan.Record interface

Jump to

Keyboard shortcuts

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