formatter

package
v0.0.1-alpha-4 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FormatConfig

type FormatConfig struct {
	Output  Output
	Unwrap  bool
	Extract bool
}

FormatConfig is the format configuration used.

func Format

func Format(userRows *tableland.TableData, opts ...FormatOption) ([]byte, FormatConfig, error)

Format transforms the user rows according to the provided configuration, retuning raw json or jsonl bytes.

type FormatOption

type FormatOption func(*FormatConfig)

FormatOption controls the behavior of calls to Format.

func WithExtract

func WithExtract(extract bool) FormatOption

WithExtract specifies whether or not to extract the JSON object from the single property of the surrounding JSON object. Default is false.

func WithOutput

func WithOutput(output Output) FormatOption

WithOutput specifies the output format. Default is Table.

func WithUnwrap

func WithUnwrap(unwrap bool) FormatOption

WithUnwrap specifies whether or not to unwrap the returned JSON objects from their surrounding array. Default is false.

type Output

type Output string

Output is used to control the output format of a query specified with the "output" query param.

const (
	// Table returns the query results as a JSON object with columns and rows properties.
	Table Output = "table"
	// Objects returns the query results as a JSON array of JSON objects. This is the default.
	Objects Output = "objects"
)

func OutputFromString

func OutputFromString(o string) (Output, bool)

OutputFromString converts a string into an Output.

Jump to

Keyboard shortcuts

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