store

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verify

func Verify(id string) error

Verify returns true if the given string represents a valid unique identifier, otherwise returns false

Types

type AGraphNode

type AGraphNode interface {
	// NodeID returns the internal graph node identifier
	NodeID() string
}

AGraphNode represents an arbitrary graph node

type GraphNode

type GraphNode struct {
	UID string
}

GraphNode represents a graph node base

func (GraphNode) NodeID

func (gn GraphNode) NodeID() string

NodeID implements the AGraphNode interface

type ID

type ID string

ID represents a universally unique identifier

func NewID

func NewID() ID

NewID creates a new random universally unique identifier

func (ID) ImplementsGraphQLType

func (id ID) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType implements the GraphQL scalar type interface

func (*ID) UnmarshalGraphQL

func (id *ID) UnmarshalGraphQL(input interface{}) (err error)

UnmarshalGraphQL implements the GraphQL scalar type interface

type MutableStore

type MutableStore interface {
	CreateSession(
		ctx context.Context,
		key string,
		creationTime time.Time,
		email string,
		password string,
	) (
		result Session,
		err error,
	)

	CloseSession(
		ctx context.Context,
		key string,
	) (
		result bool,
		err error,
	)

	CloseAllSessions(
		ctx context.Context,
		user ID,
	) (
		result []string,
		err error,
	)

	CreatePost(
		ctx context.Context,
		creationTime time.Time,
		author ID,
		title string,
		contents string,
	) (
		result Post,
		err error,
	)

	CreateReaction(
		ctx context.Context,
		creationTime time.Time,
		author ID,
		subject ID,
		emotion emotion.Emotion,
		message string,
	) (
		result Reaction,
		err error,
	)

	CreateUser(
		ctx context.Context,
		creationTime time.Time,
		email string,
		displayName string,
		passwordHash string,
	) (
		result User,
		err error,
	)

	EditPost(
		ctx context.Context,
		post ID,
		editor ID,
		newTitle *string,
		newContents *string,
	) (
		result Post,
		changes struct {
			Title    bool
			Contents bool
		},
		err error,
	)

	EditUser(
		ctx context.Context,
		user ID,
		editor ID,
		newEmail *string,
		newPassword *string,
	) (
		result User,
		changes struct {
			Email    bool
			Password bool
		},
		err error,
	)

	EditReaction(
		ctx context.Context,
		reaction ID,
		editor ID,
		newMessage string,
	) (
		result Reaction,
		changes struct {
			Message bool
		},
		err error,
	)
}

MutableStore interfaces a transactional store

type Post

type Post struct {
	GraphNode

	ID        ID
	Creation  time.Time
	Author    *User
	Title     string
	Contents  string
	Reactions []Reaction
}

Post represents a Post entity

type Reaction

type Reaction struct {
	GraphNode

	ID        ID
	Subject   AGraphNode
	Creation  time.Time
	Author    *User
	Message   string
	Emotion   emotion.Emotion
	Reactions []Reaction
}

Reaction represents a Reaction entity

type Session

type Session struct {
	GraphNode

	Key      string
	Creation time.Time
	User     *User
}

Session represents a Session entity

type Store

type Store interface {
	Prepare() error

	MutableStore

	Query(
		ctx context.Context,
		query string,
		result interface{},
	) error

	QueryVars(
		ctx context.Context,
		query string,
		vars map[string]string,
		result interface{},
	) error
}

Store interfaces a store implementation

type User

type User struct {
	GraphNode

	ID                 ID
	Creation           time.Time
	Email              string
	DisplayName        string
	Password           string
	Posts              []Post
	Sessions           []Session
	PublishedReactions []Reaction
}

User represents a User entity

Directories

Path Synopsis
enum

Jump to

Keyboard shortcuts

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