partiql

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeMarshaler = func(t time.Time) any {
	return t.Format(time.RFC3339Nano)
}

DefaultTimeMarshaler converts a time.Time into a string using the RFC3339Nano format.

Functions

func Marshal

func Marshal(value any) ([]byte, error)

Marshal returns the PartiQL encoding of v using a default encoder.

Types

type Builder

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

func NewPartiQLBuilder

func NewPartiQLBuilder() *Builder

func (*Builder) Reset

func (pb *Builder) Reset()

func (*Builder) String

func (pb *Builder) String() string

func (*Builder) WithStringBuilder

func (pb *Builder) WithStringBuilder(sb *strings.Builder) *Builder

func (*Builder) WriteBeginArray

func (pb *Builder) WriteBeginArray() *Builder

func (*Builder) WriteBeginBag

func (pb *Builder) WriteBeginBag() *Builder

func (*Builder) WriteBeginTuple

func (pb *Builder) WriteBeginTuple()

func (*Builder) WriteBoolean

func (pb *Builder) WriteBoolean(value bool) *Builder

func (*Builder) WriteBooleanArray

func (pb *Builder) WriteBooleanArray(values []bool) *Builder

func (*Builder) WriteBooleanBag

func (pb *Builder) WriteBooleanBag(values []bool) *Builder

func (*Builder) WriteEndArray

func (pb *Builder) WriteEndArray() *Builder

func (*Builder) WriteEndBag

func (pb *Builder) WriteEndBag() *Builder

func (*Builder) WriteEndTuple

func (pb *Builder) WriteEndTuple()

func (*Builder) WriteFloat

func (pb *Builder) WriteFloat(value float64) *Builder

func (*Builder) WriteFloatArray

func (pb *Builder) WriteFloatArray(values []float64) *Builder

func (*Builder) WriteFloatBag

func (pb *Builder) WriteFloatBag(values []float64) *Builder

func (*Builder) WriteInteger

func (pb *Builder) WriteInteger(value int64) *Builder

func (*Builder) WriteIntegerArray

func (pb *Builder) WriteIntegerArray(values []int) *Builder

func (*Builder) WriteIntegerBag

func (pb *Builder) WriteIntegerBag(values []int) *Builder

func (*Builder) WriteKey

func (pb *Builder) WriteKey(name string) *Builder

func (*Builder) WriteNull

func (pb *Builder) WriteNull() *Builder

func (*Builder) WriteString

func (pb *Builder) WriteString(value string) *Builder

func (*Builder) WriteStringArray

func (pb *Builder) WriteStringArray(values []string) *Builder

func (*Builder) WriteStringBag

func (pb *Builder) WriteStringBag(values []string) *Builder

func (*Builder) WriteUInteger

func (pb *Builder) WriteUInteger(value uint64) *Builder

func (*Builder) WriteUIntegerArray

func (pb *Builder) WriteUIntegerArray(values []uint) *Builder

func (*Builder) WriteUIntegerBag

func (pb *Builder) WriteUIntegerBag(values []uint) *Builder

type Encoder

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

Encoder is a PartiQL encoder that can be configured.

func NewEncoder

func NewEncoder() *Encoder

NewEncoder returns a new PartiQL encoder with default settings.

func (*Encoder) Marshal

func (e *Encoder) Marshal(value any) ([]byte, error)

Marshal returns the PartiQL encoding of value.

func (*Encoder) MarshalCollection

func (e *Encoder) MarshalCollection(value any, asBag bool) ([]byte, error)

MarshalCollection returns the PartiQL encoding of value as a collection. It will force the value to be encoded as a Bag if asBag is true.

func (*Encoder) WithTagNames

func (e *Encoder) WithTagNames(tagNames ...string) *Encoder

WithTagNames sets the tag names to be used by the encoder. It must contain at least one tag name.

func (*Encoder) WithTimeMarshaler

func (e *Encoder) WithTimeMarshaler(marshaler TimeMarshaler) *Encoder

WithTimeMarshaler sets the time marshaler to be used by the encoder.

type Marshaler

type Marshaler interface {
	MarshalPartiQL() (any, error)
}

Marshaler is the interface implemented by objects that can marshal themselves into PartiQL.

type TimeMarshaler

type TimeMarshaler func(t time.Time) any

TimeMarshaler is a function that can be used to encode time.Time values into another go value to be converted into PartiQL. Check the DefaultTimeMarshaler for an example.

Jump to

Keyboard shortcuts

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