models

package
v0.0.0-...-67e99f8 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EventBucket *gocb.Bucket
View Source
var ReadBucket *gocb.Bucket

Functions

func ConnectToCouchBase

func ConnectToCouchBase(host, user, password string)

func DeleteReadModel

func DeleteReadModel(id string) (gocb.Cas, error)

func UpsertEventStore

func UpsertEventStore(id string, eventStore EventStore) (gocb.Cas, error)

func UpsertReadModel

func UpsertReadModel(id string, model interface{}) (gocb.Cas, error)

Types

type Event

type Event struct {
	EventType string
	Payload   Post
}

type EventStore

type EventStore struct {
	Store []Event
}

func AddEventToEventStore

func AddEventToEventStore(eventStore EventStore, event Event) (EventStore, bool)

func GetEventStore

func GetEventStore(id string) (EventStore, gocb.Cas, error)

type Post

type Post struct {
	ID        uint64    `json:"id"`
	Title     string    `json:"title"`
	Content   string    `json:"content"`
	AuthorID  uint32    `json:"author_id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func BuildPostReadModel

func BuildPostReadModel(id string, eventStore EventStore) (Post, error)

func GetReadModel

func GetReadModel(id string) (Post, gocb.Cas, error)

type User

type User struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Nickname  string    `gorm:"size:255;not null;unique" json:"nickname"`
	Email     string    `gorm:"size:100;not null;unique" json:"email"`
	Password  string    `gorm:"size:100;not null;" json:"password"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

Jump to

Keyboard shortcuts

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