db

package
v0.0.0-...-25593b2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2017 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	NewTopic(name, description string, user *User) (*Topic, error)
	TopicById(Id string) (*Topic, error)
	TopicsByUser(user *User) ([]*Topic, error)
	QuestionsForTopic(topicId string, user *User) ([]*Question, error)
	NewQuestion(topicId, question string, user *User) (*Question, error)
	VoteForQuestion(questionId string, user *User) error
	UnvoteForQuestion(questionId string, user *User) error
}

func NewMongoDB

func NewMongoDB(mongoURL string) (DB, error)

type MongoDB

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

func (*MongoDB) NewQuestion

func (mongodb *MongoDB) NewQuestion(topicId, question string, user *User) (*Question, error)

func (*MongoDB) NewTopic

func (mongodb *MongoDB) NewTopic(name, description string, user *User) (*Topic, error)

func (*MongoDB) QuestionsForTopic

func (mongodb *MongoDB) QuestionsForTopic(topicId string, user *User) ([]*Question, error)

func (*MongoDB) TopicById

func (mongodb *MongoDB) TopicById(Id string) (*Topic, error)

func (*MongoDB) TopicsByUser

func (mongodb *MongoDB) TopicsByUser(user *User) ([]*Topic, error)

func (*MongoDB) UnvoteForQuestion

func (mongodb *MongoDB) UnvoteForQuestion(questionId string, user *User) error

func (*MongoDB) VoteForQuestion

func (mongodb *MongoDB) VoteForQuestion(questionId string, user *User) error

type Question

type Question struct {
	Id          string
	TopicId     string
	Question    string
	User        User
	Created     time.Time
	Votes       int
	UserCanVote bool
}

type Topic

type Topic struct {
	Id          string
	Name        string
	Description string
	User        User
	Created     time.Time
}

type User

type User struct {
	GoogleId string
	Username string
}

Jump to

Keyboard shortcuts

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