bookshelf

package
v0.0.0-...-400b447 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2017 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package bookshelf contains the bookshelf database and app configuration, shared by the main app module and the worker module.

Index

Constants

View Source
const PubsubTopicID = "fill-book-details"

Variables

View Source
var (
	DB          BookDatabase
	OAuthConfig *oauth2.Config

	StorageBucket     *storage.BucketHandle
	StorageBucketName string

	SessionStore sessions.Store

	PubsubClient *pubsub.Client
)

Functions

This section is empty.

Types

type Book

type Book struct {
	ID            int64
	Title         string
	Author        string
	PublishedDate string
	ImageURL      string
	Description   string
	CreatedBy     string
	CreatedByID   string
}

Book holds metadata about a book.

func (*Book) CreatedByDisplayName

func (b *Book) CreatedByDisplayName() string

CreatedByDisplayName returns a string appropriate for displaying the name of the user who created this book object.

func (*Book) SetCreatorAnonymous

func (b *Book) SetCreatorAnonymous()

SetCreatorAnonymous sets the CreatedByID field to the "anonymous" ID.

type BookDatabase

type BookDatabase interface {
	// ListBooks returns a list of books, ordered by title.
	ListBooks() ([]*Book, error)

	// ListBooksCreatedBy returns a list of books, ordered by title, filtered by
	// the user who created the book entry.
	ListBooksCreatedBy(userID string) ([]*Book, error)

	// GetBook retrieves a book by its ID.
	GetBook(id int64) (*Book, error)

	// AddBook saves a given book, assigning it a new ID.
	AddBook(b *Book) (id int64, err error)

	// DeleteBook removes a given book by its ID.
	DeleteBook(id int64) error

	// UpdateBook updates the entry for a given book.
	UpdateBook(b *Book) error

	// Close closes the database, freeing up any available resources.
	// TODO(cbro): Close() should return an error.
	Close()
}

BookDatabase provides thread-safe access to a database of books.

type MySQLConfig

type MySQLConfig struct {
	// Optional.
	Username, Password string

	// Required.
	Host string
	Port int
}

Directories

Path Synopsis
Sample bookshelf is a fully-featured app demonstrating several Google Cloud APIs, including Datastore, Cloud SQL, Cloud Storage.
Sample bookshelf is a fully-featured app demonstrating several Google Cloud APIs, including Datastore, Cloud SQL, Cloud Storage.
Sample pubsub_worker demonstrates the use of the Cloud Pub/Sub API to communicate between two modules.
Sample pubsub_worker demonstrates the use of the Cloud Pub/Sub API to communicate between two modules.

Jump to

Keyboard shortcuts

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