db

package
v0.0.0-...-90cde1e Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntityCollectionName = "entities"
)

Variables

View Source
var (
	ErrorConnecting   = trace.New("ERROR_CONNECTING")
	ErrorNotConnected = trace.New("ERROR_NOT_CONNECTED")
	ErrorPinging      = trace.New("ERROR_PINGING")
)
View Source
var (
	ErrorInvalidEntity   = trace.New("ERROR_INVALID_ENTITY")
	ErrorMarshalEntity   = trace.New("ERROR_MARSHAL_ENTITY")
	ErrorUnmarshalEntity = trace.New("ERROR_UNMARSHAL_ENTITY")
)

Functions

func DeleteEntity

func DeleteEntity(ctx context.Context, id string) error

func DeleteFacet

func DeleteFacet(ctx context.Context, logger util.Logger, id string) error

func Healthcheck

func Healthcheck(ctx context.Context) error

func IndexFromBson

func IndexFromBson(input bson.D)

func NewConnection

func NewConnection(ctx context.Context, logger util.Logger) (*mongo.Client, error)

Types

type Entity

type Entity struct {
	ID         string                 `bson:"_id"        json:"_id,omitempty"`
	Dir        string                 `bson:"dir"        json:"dir"`
	Base       string                 `bson:"base"       json:"base"`
	Attributes map[string]interface{} `bson:"attributes" json:"attributes"`
	CreatedAt  time.Time              `bson:"created_at" json:"created_at"`
	UpdatedAt  time.Time              `bson:"updated_at" json:"updated_at"`
}

func CreateEntity

func CreateEntity(ctx context.Context, path string, attributes map[string]interface{}) (*Entity, error)

func GetEntity

func GetEntity(ctx context.Context, id string) (*Entity, error)

func ListEntities

func ListEntities(ctx context.Context, filter interface{}) ([]*Entity, error)

func NewEntity

func NewEntity(path string, attributes map[string]interface{}) *Entity

func UpdateEntity

func UpdateEntity(ctx context.Context, id string, attributes map[string]interface{}) (*Entity, error)

type EntityAttributes

type EntityAttributes struct {
	Path       string                 `bson:"path"       json:"path"`
	Attributes map[string]interface{} `bson:"attributes" json:"attributes"`
}

func EntityAttributesFromBytes

func EntityAttributesFromBytes(input []byte) (*EntityAttributes, error)

type EntityMeta

type EntityMeta struct {
	Indicies []string
}

type Facet

type Facet struct {
	Id   string   `json:"id"`
	Key  string   `json:"key"`
	Sort SortType `json:"sort"`
}

func AssertFacet

func AssertFacet(ctx context.Context, key string, sort SortType) (*Facet, error)

func CreateFacet

func CreateFacet(ctx context.Context, logger util.Logger, key string, sort SortType) (*Facet, error)

func FacetFromBson

func FacetFromBson(raw interface{}) (*Facet, error)

func FacetFromBytes

func FacetFromBytes(raw []byte) (*Facet, error)

func ListFacets

func ListFacets(ctx context.Context, logger util.Logger) ([]*Facet, error)

type Index

type Index struct {
	ID   primitive.ObjectID `bson:"_id"  json:"_id,omitempty"`
	Name string             `bson:"name" json:"name"`
}

type SortType

type SortType = int32
const (
	SortAsc SortType = 1
	SortDes SortType = -1
)

Jump to

Keyboard shortcuts

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