view

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

README

view

import "github.com/coralproject/shelf/internal/wire/view"

Overview

Index

Package files

model.go view.go

Constants

const Collection = "views"

Collection is the Mongo collection containing view metadata.

Variables

var ErrNotFound = errors.New("View Not found")

ErrNotFound is an error variable thrown when no results are returned from a Mongo query.

func Delete

func Delete(context interface{}, db *db.DB, name string) error

Delete removes a view from from Mongo.

func GetAll

func GetAll(context interface{}, db *db.DB) ([]View, error)

GetAll retrieves the current views from Mongo.

func Upsert

func Upsert(context interface{}, db *db.DB, view *View) error

Upsert upserts a view to the collection of currently utilized views.

type Path

type Path struct {
    StrictPath bool         `bson:"strict_path" json:"strict_path"`
    Segments   PathSegments `bson:"path_segments" json:"path_segments" validate:"required,min=1"`
}

Path includes information defining one or multiple graph paths, along with a boolean choice for whether or not the path is a strict graph path.

func (*Path) Validate
func (path *Path) Validate() error

Validate checks the pathsegment value for consistency.

type PathSegment

type PathSegment struct {
    Level     int    `bson:"level" json:"level" validate:"required,min=1"`
    Direction string `bson:"direction" json:"direction" validate:"required,min=2"`
    Predicate string `bson:"predicate" json:"predicate" validate:"required,min=1"`
    Tag       string `bson:"tag,omitempty" json:"tag,omitempty"`
}

PathSegment contains metadata about a segment of a path, which path partially defines a View.

func (*PathSegment) Validate
func (ps *PathSegment) Validate() error

Validate checks the pathsegment value for consistency.

type PathSegments

type PathSegments []PathSegment

PathSegments is a slice of PathSegment values.

func (PathSegments) Len
func (slice PathSegments) Len() int

Len is required to sort a slice of PathSegment.

func (PathSegments) Less
func (slice PathSegments) Less(i, j int) bool

Less is required to sort a slice of PathSegment.

func (PathSegments) Swap
func (slice PathSegments) Swap(i, j int)

Swap is required to sort a slice of PathSegment.

type View

type View struct {
    Name       string `bson:"name" json:"name" validate:"required,min=3"`
    Collection string `bson:"collection" json:"collection" validate:"required,min=2"`
    StartType  string `bson:"start_type" json:"start_type" validate:"required,min=3"`
    ReturnRoot bool   `bson:"return_root,omitempty" json:"return_root,omitempty"`
    Paths      []Path `bson:"paths" json:"paths" validate:"required,min=1"`
}

View contains metadata about a view.

func GetByName
func GetByName(context interface{}, db *db.DB, name string) (*View, error)

GetByName retrieves a view by name from Mongo.

func (*View) Validate
func (v *View) Validate() error

Validate checks the View value for consistency.


Generated by godoc2md

Documentation

Index

Constants

View Source
const Collection = "views"

Collection is the Mongo collection containing view metadata.

Variables

View Source
var ErrNotFound = errors.New("View Not found")

ErrNotFound is an error variable thrown when no results are returned from a Mongo query.

Functions

func Delete

func Delete(context interface{}, db *db.DB, name string) error

Delete removes a view from from Mongo.

func Upsert

func Upsert(context interface{}, db *db.DB, view *View) error

Upsert upserts a view to the collection of currently utilized views.

Types

type Path

type Path struct {
	StrictPath bool         `bson:"strict_path" json:"strict_path"`
	Segments   PathSegments `bson:"path_segments" json:"path_segments" validate:"required,min=1"`
}

Path includes information defining one or multiple graph paths, along with a boolean choice for whether or not the path is a strict graph path.

func (*Path) Validate added in v0.4.2

func (path *Path) Validate() error

Validate checks the pathsegment value for consistency.

type PathSegment

type PathSegment struct {
	Level     int    `bson:"level" json:"level" validate:"required,min=1"`
	Direction string `bson:"direction" json:"direction" validate:"required,min=2"`
	Predicate string `bson:"predicate" json:"predicate" validate:"required,min=1"`
	Tag       string `bson:"tag,omitempty" json:"tag,omitempty"`
}

PathSegment contains metadata about a segment of a path, which path partially defines a View.

func (*PathSegment) Validate

func (ps *PathSegment) Validate() error

Validate checks the pathsegment value for consistency.

type PathSegments added in v0.4.2

type PathSegments []PathSegment

PathSegments is a slice of PathSegment values.

func (PathSegments) Len added in v0.4.2

func (slice PathSegments) Len() int

Len is required to sort a slice of PathSegment.

func (PathSegments) Less added in v0.4.2

func (slice PathSegments) Less(i, j int) bool

Less is required to sort a slice of PathSegment.

func (PathSegments) Swap added in v0.4.2

func (slice PathSegments) Swap(i, j int)

Swap is required to sort a slice of PathSegment.

type View

type View struct {
	Name       string `bson:"name" json:"name" validate:"required,min=3"`
	Collection string `bson:"collection" json:"collection" validate:"required,min=2"`
	StartType  string `bson:"start_type" json:"start_type" validate:"required,min=3"`
	ReturnRoot bool   `bson:"return_root,omitempty" json:"return_root,omitempty"`
	Paths      []Path `bson:"paths" json:"paths" validate:"required,min=1"`
}

View contains metadata about a view.

func GetAll

func GetAll(context interface{}, db *db.DB) ([]View, error)

GetAll retrieves the current views from Mongo.

func GetByName

func GetByName(context interface{}, db *db.DB, name string) (*View, error)

GetByName retrieves a view by name from Mongo.

func (*View) Validate

func (v *View) Validate() error

Validate checks the View value for consistency.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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