models

package
v0.0.0-...-e6a0c96 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

The models package provides a means of communicating with the database

In your main function Initialise:

getList := make(chan ListRetrieve)
addList := make(chan AddRequest)
removeList := make(chan string)
go BookmarksCollection(getList, addList, removeList)

This runs the bookmarks collection and provides channels for requests.

To make requests of the database, do the following:

1. Retrieve a list

key := keyToRetrieve
reply := make(chan Bookmarks)
getList <- ListRetrieve{key, reply}
newList := <- reply

2. Add a list

bookmarks := bookmarksToInsert
reply := make(chan string)
addList <- AddRequest{bookmarks, reply}
newKey := <- reply

3. Remove a list

key := keyToDelete
removeList <- key

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BookmarksCollection

func BookmarksCollection(getList chan ListRetrieve,
	addList chan AddRequest,
	removeList chan string)

BookmarksCollection maintains the bookmarks collection and serves requests. It provides channels for retrieval, insertion, and removal. It communicates to WordList via the code channel.

func Database

func Database(newColRequest chan ColRequest)

Database starts a session on the database and provides channels for other functions to take control over certain collections

func MetaSearch

func MetaSearch(tags []Tag, metamarks *mgo.Collection) *mgo.Iter

MetaSearch searches by semantic tags and returns an iterator which can be used to iterate over the results.

func SearchForPages

func SearchForPages(s string, metamarks *mgo.Collection, results chan MetaMark)

SearchForPages

func UniqueCodeTracker

func UniqueCodeTracker(newCode chan string, freeCode chan string, colRequest chan ColRequest)

UniqueCodeTracker initialises and maintains the register of which codes are in use. It serves requests for new unique codes, and requests to free expired codes. word is a channel for communicating with WordList.

func WordList

func WordList(word chan string, newColRequest chan ColRequest, quit chan bool)

WordList initialises and maintains the goside of the words collection from the database. It servesstring requests for random words via the word channel. These requests come from UniqueCodeTracker.

Types

type AddRequest

type AddRequest struct {
	List  Bookmarks
	Reply chan string // Return the key
}

AddRequest stores a request for adding a Bookmarks object to the bookmarks collection

type Bookmark

type Bookmark struct {
	//  Id	bson.ObjectId 	`json:"id"	bson:"_id"`
	URL         string "url"
	Description string "description"
}

Bookmark stores a single bookmark. The user of the package should initialise the URL and Description fields.

type Bookmarks

type Bookmarks struct {
	//  Id		bson.ObjectId 	`json:"id"	bson:"_id"`
	Key     string     "key"
	Created time.Time  "created"
	Viewed  time.Time  "viewed"
	List    []Bookmark "list"
}

Bookmarks stores a list of bookmarks. The Key which is generated when the object is passed to the collection. The Created and Viewed fields are maintained by the collection. The user of the package should initialise the List field.

type CodeRequest

type CodeRequest struct {
	// contains filtered or unexported fields
}
WordRepo struct {
	Collection *mgo.Collection
}

type ColRequest

type ColRequest struct {
	// contains filtered or unexported fields
}

Request for a handle of a collection

type ListRetrieve

type ListRetrieve struct {
	Key   string
	Reply chan Bookmarks // Returns the Bookmarks object found
}

ListRetrieve stores a request for retrieving a Bookmarks object from the bookmarks collection by key

type MetaMark

type MetaMark struct {
	// contains filtered or unexported fields
}

func (*MetaMark) CreateMetaMark

func (m *MetaMark) CreateMetaMark() error

CreateMetaMark pushes the information in m to the metamark collection of the database as a document.

func (*MetaMark) DestroyMetaMark

func (m *MetaMark) DestroyMetaMark() error

DestroyMetaMark removes the metamark in the database with url = m.url

func (*MetaMark) ReadMetaMark

func (m *MetaMark) ReadMetaMark() error

ReadMetaMark uses m.url to pull the matching metamark into m from the metamark collection of the database.

func (*MetaMark) UpdateMetaMark

func (m *MetaMark) UpdateMetaMark() error

UpdateMetaMark uses the data in m to modify the matching metamark in the metamark collection of the database. Any tags not present in m are removed in the document corresponding to m.url. This function could use some thought because the changes we want to make will be "adding tags", "removing tags", "modifying the weight of tags", and from the mongo perspective we don't have to read the metamark to know how to update it properly.

type Tag

type Tag struct {
	// contains filtered or unexported fields
}

type Url

type Url string

We should use a Url type to add constraints

type Word

type Word struct {
	//Key  int    "k"
	Word string "w"
}

Jump to

Keyboard shortcuts

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