relationship

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: 7 Imported by: 0

README

relationship

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

Overview

Index

Package files

model.go relationship.go

Constants

const Collection = "relationships"

Collection is the Mongo collection containing relationship metadata.

Variables

var ErrNotFound = errors.New("Relationship 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, predicate string) error

Delete removes a relationship from from Mongo.

func GetAll

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

GetAll retrieves the current relationships from Mongo.

func Upsert

func Upsert(context interface{}, db *db.DB, rel *Relationship) error

Upsert upserts a relationship to the collection of currently utilized relationships.

type Relationship

type Relationship struct {
    SubjectTypes []string `bson:"subject_types" json:"subject_types" validate:"required,min=1"`
    Predicate    string   `bson:"predicate" json:"predicate" validate:"required,min=2"`
    ObjectTypes  []string `bson:"object_types" json:"object_types" validate:"required,min=1"`
    InString     string   `bson:"in_string,omitempty" json:"in_string,omitempty"`
    OutString    string   `bson:"out_string,omitempty" json:"out_string,omitempty"`
}

Relationship contains metadata about a relationship. Note, predicate should be unique.

func GetByPredicate
func GetByPredicate(context interface{}, db *db.DB, predicate string) (*Relationship, error)

GetByPredicate retrieves a relationship by predicate from Mongo.

func (*Relationship) Validate
func (r *Relationship) Validate() error

Validate checks the Relationship value for consistency.


Generated by godoc2md

Documentation

Index

Constants

View Source
const Collection = "relationships"

Collection is the Mongo collection containing relationship metadata.

Variables

View Source
var ErrNotFound = errors.New("Relationship 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, predicate string) error

Delete removes a relationship from from Mongo.

func Upsert

func Upsert(context interface{}, db *db.DB, rel *Relationship) error

Upsert upserts a relationship to the collection of currently utilized relationships.

Types

type Relationship

type Relationship struct {
	SubjectTypes []string `bson:"subject_types" json:"subject_types" validate:"required,min=1"`
	Predicate    string   `bson:"predicate" json:"predicate" validate:"required,min=2"`
	ObjectTypes  []string `bson:"object_types" json:"object_types" validate:"required,min=1"`
	InString     string   `bson:"in_string,omitempty" json:"in_string,omitempty"`
	OutString    string   `bson:"out_string,omitempty" json:"out_string,omitempty"`
}

Relationship contains metadata about a relationship. Note, predicate should be unique.

func GetAll

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

GetAll retrieves the current relationships from Mongo.

func GetByPredicate

func GetByPredicate(context interface{}, db *db.DB, predicate string) (*Relationship, error)

GetByPredicate retrieves a relationship by predicate from Mongo.

func (*Relationship) Validate

func (r *Relationship) Validate() error

Validate checks the Relationship value for consistency.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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