sqlite

package
v0.0.0-...-c4bde49 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Model
	Slug        string `gorm:"unique_index;not null"`
	Title       string `gorm:"not null"`
	Description string
	Body        string
	Author      User
	AuthorID    int64
	Comments    []Comment
	Favorites   []User `gorm:"many2many:favorites;"`
	Tags        []Tag  `gorm:"many2many:article_tags;association_autocreate:false"`
}

type Comment

type Comment struct {
	Model
	Article   Article
	ArticleID int64
	User      User
	UserID    int64
	Body      string
}

type Follow

type Follow struct {
	Follower    User
	FollowerID  int64 `gorm:"primary_key" sql:"type:int not null"`
	Following   User
	FollowingID int64 `gorm:"primary_key" sql:"type:int not null"`
}

type Model

type Model struct {
	ID        int64 `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

type Storage

type Storage struct {
	DB *gorm.DB
}

func NewStorage

func NewStorage(filename string) (*Storage, error)

func (*Storage) Migrate

func (s *Storage) Migrate()

func (*Storage) NewArticleRepository

func (s *Storage) NewArticleRepository() realworld.ArticleRepo

func (*Storage) NewUserRepository

func (s *Storage) NewUserRepository() realworld.UserRepo

type Tag

type Tag struct {
	Model
	Tag      string    `gorm:"unique_index"`
	Articles []Article `gorm:"many2many:article_tags;"`
}

type User

type User struct {
	Model
	Username   string `gorm:"unique_index;not null"`
	Email      string `gorm:"unique_index;not null"`
	Password   string `gorm:"not null"`
	Bio        sql.NullString
	Image      sql.NullString
	Followers  []Follow  `gorm:"foreignkey:FollowingID"`
	Followings []Follow  `gorm:"foreignkey:FollowerID"`
	Favorites  []Article `gorm:"many2many:favorites;"`
}

Jump to

Keyboard shortcuts

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