faststore

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2015 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package faststore is a collection of stores that are optimzed and not neccesarly of the same interface as a url.Store

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastStorer

type FastStorer interface {
	AddURL(URLModel)
	GetURL(id string) (URLModel, error)
	AllURLs() ([]URLModel, error)
}

A FastStorer is an interface that allows URL models to be quickly stored.

type URLModel

type URLModel struct {
	ID   bson.ObjectId `bson:"_id"`
	Slug string        `bson:"slug"`
	URL  string        `bson:"url"`
}

A URLModel abstracts the fields.

type URLMongoStore

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

A URLMongoStore represents a persistent connection to a mongo backend.

func NewURLMongoStore

func NewURLMongoStore(uri string) (s *URLMongoStore, err error)

NewURLMongoStore is a factory function to return a valid URLMongoStore.

func (*URLMongoStore) AddURL

func (s *URLMongoStore) AddURL(model URLModel)

AddURL adds the given URLModel to the mongodb

func (*URLMongoStore) AllURLs

func (s *URLMongoStore) AllURLs() (models []URLModel, err error)

AllURLs aggregates all model records.

func (*URLMongoStore) GetURL

func (s *URLMongoStore) GetURL(id string) (model URLModel, err error)

GetURL attempts to find a record with the given slug. If no record is found an error is returned.

Jump to

Keyboard shortcuts

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