bookshelf

package
v0.0.0-...-7a23ab9 Latest Latest
Warning

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

Go to latest
Published: May 2, 2019 License: Apache-2.0 Imports: 17 Imported by: 2

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(context.Context) ([]*Book, error)

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

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

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

	// DeleteBook removes a given book by its ID.
	DeleteBook(ctx context.Context, id int64) error

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

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

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

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