path

package
v0.0.0-...-284eadf Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SepInService  = "/"
	SepInDatabase = "."
)

Following constants are used while saving and displaying Path type to and from database

Variables

This section is empty.

Functions

func ToExpression

func ToExpression(p Path, this uuid.UUID) string

ToExpression returns a string in ltree format. Joins UUIDs in the first argument using `.` Second argument is converted and appended if needed

Types

type Path

type Path []uuid.UUID

Path type helps in storing and retrieving ltree fields to and from databse. It uses ltree knowledge while converting values. https://www.postgresql.org/docs/9.1/static/ltree.html It is just slice of UUIDs which will be saved to database in following format 4dd8f038_3fc4_48ab_ad4d_197ccc7b44a2.62ea5454_f8d5_4b35_8589_8d646d612250.c9b24b8f_8b33_4c22_82f0_8eb0a5b9837e Above content will be read from database as a slice of UUIDs

func (Path) Convert

func (p Path) Convert() string

Convert returns ltree compatible string of UUID slice 39fa8c5b_5732_436f_a084_0f2a247f3435.87762c8b_17f9_4cbb_b355_251b6a524f2f

func (Path) ConvertToLtree

func (p Path) ConvertToLtree(id uuid.UUID) string

ConvertToLtree returns ltree form of given UUID

func (Path) IsEmpty

func (p Path) IsEmpty() bool

IsEmpty checks count of items in Path

func (Path) MarshalJSON

func (p Path) MarshalJSON() ([]byte, error)

MarshalJSON allows Path to be serialized

func (Path) Parent

func (p Path) Parent() Path

Parent returns a Path instance with last element in the UUID slice Similar to `This` but following funtion returns Path instance and not just UUID

func (Path) Root

func (p Path) Root() Path

Root retunrs a Path instance with first element in the UUID slice

func (*Path) Scan

func (p *Path) Scan(value interface{}) error

Scan helps in implementing Scanner interface on Path

func (Path) String

func (p Path) String() string

String converts the Path to representable format in string Currently separator is '/' /87762c8b-17f9-4cbb-b355-251b6a524f2f/39fa8c5b-5732-436f-a084-0f2a247f3435/be54f2c4-cfa4-47af-ad06-280fba540872

func (Path) This

func (p Path) This() uuid.UUID

This returns last UUID of slice

func (*Path) UnmarshalJSON

func (p *Path) UnmarshalJSON(b []byte) error

UnmarshalJSON allows Path to be deserialized

func (Path) Value

func (p Path) Value() (driver.Value, error)

Value helps in implementing Valuer interfae on Path This conversion uses Ltree specification

Jump to

Keyboard shortcuts

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