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 ¶
- func BookmarksCollection(getList chan ListRetrieve, addList chan AddRequest, removeList chan string)
- func Database(newColRequest chan ColRequest)
- func MetaSearch(tags []Tag, metamarks *mgo.Collection) *mgo.Iter
- func SearchForPages(s string, metamarks *mgo.Collection, results chan MetaMark)
- func UniqueCodeTracker(newCode chan string, freeCode chan string, colRequest chan ColRequest)
- func WordList(word chan string, newColRequest chan ColRequest, quit chan bool)
- type AddRequest
- type Bookmark
- type Bookmarks
- type CodeRequest
- type ColRequest
- type ListRetrieve
- type MetaMark
- type Tag
- type Url
- type Word
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 ¶
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 ¶
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 ¶
CreateMetaMark pushes the information in m to the metamark collection of the database as a document.
func (*MetaMark) DestroyMetaMark ¶
DestroyMetaMark removes the metamark in the database with url = m.url
func (*MetaMark) ReadMetaMark ¶
ReadMetaMark uses m.url to pull the matching metamark into m from the metamark collection of the database.
func (*MetaMark) UpdateMetaMark ¶
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.