package
0.4.8
Repository: https://github.com/coralproject/shelf.git
Documentation: pkg.go.dev

# 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

# Packages

No description provided by the author

# Functions

Delete removes a view from from Mongo.
GetAll retrieves the current views from Mongo.
GetByName retrieves a view by name from Mongo.
Upsert upserts a view to the collection of currently utilized views.

# Constants

Collection is the Mongo collection containing view metadata.

# Variables

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

# Structs

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.
PathSegment contains metadata about a segment of a path, which path partially defines a View.
View contains metadata about a view.

# Type aliases

PathSegments is a slice of PathSegment values.