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

# README

item

import "github.com/coralproject/shelf/internal/sponge/item"

Overview

Index

Package files

item.go model.go

Constants

const Collection = "items"

Collection is the Mongo collection containing item values.

Variables

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

Delete removes an item from from Mongo.

func GetByIDs

func GetByIDs(context interface{}, db *db.DB, ids []string) ([]Item, error)

GetByIDs retrieves items by ID from Mongo.

func Upsert

func Upsert(context interface{}, db *db.DB, item *Item) error

Upsert upserts an item to the items collections.

type Item

type Item struct {
    ID        string                 `bson:"item_id" json:"item_id" validate:"required,min=1"`
    Type      string                 `bson:"type" json:"type" validate:"required,min=2"`
    Version   int                    `bson:"version" json:"version" validate:"required,min=1"`
    Data      map[string]interface{} `bson:"data" json:"data"`
    CreatedAt time.Time              `bson:"created_at" json:"created_at"`
    UpdatedAt time.Time              `bson:"updated_at" json:"updated_at"`
    Related   map[string]interface{} `bson:"related,omitempty" json:"related,omitempty"`
}

Item is data, properties and behavior associated with one of a comment, asset, action, etc. Regardless of type (comment, asset, etc.), all Items are formatted with an ID, Type, and Version, and asssociated data (which may differ greatly between items) is encoded into the Data interface.

func GetByID

func GetByID(context interface{}, db *db.DB, id string) (Item, error)

GetByID retrieves a single item by ID from Mongo.

func (*Item) InferIDFromData

func (item *Item) InferIDFromData() error

InferIDFromData infers an item_id from type and source id.

func (*Item) Validate

func (item *Item) Validate() error

Validate validates an Item value with the validator.


Generated by godoc2md

# Packages

No description provided by the author

# Functions

Delete removes an item from from Mongo.
GetByID retrieves a single item by ID from Mongo.
GetByIDs retrieves items by ID from Mongo.
Upsert upserts an item to the items collections.

# Constants

Collection is the Mongo collection containing item values.

# Variables

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

# Structs

Item is data, properties and behavior associated with one of a comment, asset, action, etc.