model

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IdxCreators = []IndexQueryCreator{}

https://techblog.enechain.com/entry/bun-atlas-migration-setup-guide

Functions

This section is empty.

Types

type Day

type Day struct {
	bun.BaseModel `bun:"table:days,alias:d"`

	YMD   string `bun:",pk"`
	YM    string
	Count int64
	Month Month `bun:"rel:belongs-to,join:ym=ym"`
}

type File

type File struct {
	ID           string `bun:",pk"`
	Name         string
	URL          string
	ThumbnailURL string
	Type         string
	CreatedAt    time.Time
	Notes        []Note `bun:"m2m:note_to_files,join:File=Note"`
}

type HashTag

type HashTag struct {
	bun.BaseModel `bun:"table:hash_tags,alias:h"`

	ID    int64  `bun:",pk,autoincrement"`
	Text  string `bun:",unique"`
	Count int64
	Notes []Note `bun:"m2m:note_to_tags,join:HashTag=Note"`
}

type IndexQueryCreator

type IndexQueryCreator func(db *bun.DB) *bun.CreateIndexQuery

type Month

type Month struct {
	bun.BaseModel `bun:"table:months,alias:m"`

	YM    string `bun:",pk"`
	Count int64
	Days  []*Day `bun:"rel:has-many,join:ym=ym"`
}

type Note

type Note struct {
	bun.BaseModel `bun:"table:notes,alias:n"`

	ID                string `bun:",pk"`
	ReactionID        string `bun:",notnull"`
	UserID            string `bun:",notnull"` // `bun:",pk"` ここをprimary keyにするとm2mのリレーション結合が壊れる
	ReactionEmojiName string `bun:",notnull"`
	Text              string
	CreatedAt         time.Time
	User              User          `bun:"rel:belongs-to,join:user_id=id"`
	Reaction          ReactionEmoji `bun:"rel:belongs-to,join:reaction_emoji_name=name"`
	Tags              []HashTag     `bun:"m2m:note_to_tags,join:Note=HashTag"`
	Files             []File        `bun:"m2m:note_to_files,join:Note=File"`
}

type NoteToFile

type NoteToFile struct {
	NoteID string `bun:",pk"`
	Note   *Note  `bun:"rel:belongs-to,join:note_id=id"`
	FileID string `bun:",pk"`
	File   *File  `bun:"rel:belongs-to,join:file_id=id"`
}

type NoteToTag

type NoteToTag struct {
	NoteID    string   `bun:",pk"`
	Note      *Note    `bun:"rel:belongs-to,join:note_id=id"`
	HashTagID int64    `bun:",pk"`
	HashTag   *HashTag `bun:"rel:belongs-to,join:hash_tag_id=id"`
}

type ReactionEmoji added in v0.0.3

type ReactionEmoji struct {
	bun.BaseModel `bun:"table:reactions,alias:r"`

	ID    int64  `bun:",pk,autoincrement"`
	Name  string `bun:",unique,notnull"`
	Image string
	Count int64
}

type User

type User struct {
	bun.BaseModel `bun:"table:users,alias:u"`

	ID          string `bun:",pk"`
	Name        string
	DisplayName string
	AvatarURL   string
	Count       int64
}

Jump to

Keyboard shortcuts

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