data

package
v0.0.0-...-734e769 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AttributeQueryReg = regexp.MustCompile("([^:]+):?(.*)")

Functions

func AssertGuid

func AssertGuid(maybeGuid string) (val string, exists bool)

func ClearCache

func ClearCache()

func DB

func DB() (*mgo.Database, *mgo.Session)

func Files

func Files() *mgo.GridFS

func FlushCache

func FlushCache() error

func FromCache

func FromCache(key string) (string, bool)

func LoadCache

func LoadCache() error

func Objects

func Objects() *mgo.Collection

func SetCache

func SetCache(key string, data string)

Types

type Attachment

type Attachment struct {
	Id         bson.ObjectId `bson:"_id" json:"id"`
	UploadDate time.Time     `bson:"uploadDate" json:"uploadDate"`
	Filename   string        `bson:"filename" json:"filename"`
	MetaData   []KeyVal      `bson:"metadata" json:"metadata"`
	Content    string        `bson:"content" json:"content"`
}

func CreateAttachment

func CreateAttachment(file *mgo.GridFile, filename string, content string, metadata map[string]string) *Attachment

func GetAttachment

func GetAttachment(id string) (Attachment, error)

type AttributeQuery

type AttributeQuery struct {
	Name  string
	Value string
	Exact bool
}

type KeyVal

type KeyVal struct {
	Name  string `bson:"name" json:"name"`
	Value string `bson:"value" json:"value"`
}

type Object

type Object struct {
	Id          bson.ObjectId `bson:"_id,omitempty" json:"id"`
	Title       string        `bson:"title" json:"title"`
	CreateDate  time.Time     `bson:"createDate" json:"createDate"`
	Attributes  []KeyVal      `bson:"attributes" json:"attributes"`
	Attachments []Attachment  `bson:"attachments" json:"attachments"`
}

func CreateObject

func CreateObject(title string) *Object

func GetObject

func GetObject(id string) (*Object, error)

func (*Object) AddAttribute

func (o *Object) AddAttribute(name string, value string)

func (*Object) AddTag

func (o *Object) AddTag(value string)

func (*Object) AttachmentIndex

func (o *Object) AttachmentIndex(objectId string) int

func (*Object) AttributeIndex

func (o *Object) AttributeIndex(name string, value string) int

func (*Object) GetAttachment

func (o *Object) GetAttachment(objectId string) Attachment

func (Object) HasAttribute

func (o Object) HasAttribute(name string, value string) bool

func (Object) HasTag

func (o Object) HasTag(tag string) bool

func (*Object) RemoveAttachment

func (o *Object) RemoveAttachment(objectId string)

func (*Object) RemoveAttribute

func (o *Object) RemoveAttribute(name string, value string)

func (Object) RemoveTag

func (o Object) RemoveTag(tag string)

func (*Object) Update

func (o *Object) Update() error

type Query

type Query struct {
	Text           string
	AttributeQuery []AttributeQuery
}

func ParseQuery

func ParseQuery(query []string) Query

type SearchObject

type SearchObject struct {
	Id    bson.ObjectId `bson:"_id,omitempty" json:"id"`
	Title string        `bson:"title" json:"title"`
	Score float64       `bson:"score" json:"score"`
	Object
}

Jump to

Keyboard shortcuts

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