Documentation
¶
Index ¶
- func BindTime(v time.Time) int64
- func Must(c bool, format string, a ...any)
- func MustBe(c bool)
- func MustBeEqual(a, b any)
- func MustBeNil(a any)
- func MustBeSet(a any)
- func Run(makeDb func(dbfile string) Db)
- func UnbindTime(v int64) time.Time
- type Article
- type Comment
- type Db
- type SqlDb
- func (d *SqlDb) Close()
- func (d *SqlDb) DriverName() string
- func (d *SqlDb) Exec(sqls ...string)
- func (d *SqlDb) FindArticles(querySql string) []Article
- func (d *SqlDb) FindUsers(querySql string) []User
- func (d *SqlDb) FindUsersArticlesComments(querySql string) ([]User, []Article, []Comment)
- func (d *SqlDb) InsertArticles(insertSql string, articles []Article)
- func (d *SqlDb) InsertComments(insertSql string, comments []Comment)
- func (d *SqlDb) InsertUsers(insertSql string, users []User)
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustBeEqual ¶
func MustBeEqual(a, b any)
func UnbindTime ¶
Types ¶
type Article ¶
type Article struct {
Id int
Created time.Time
UserId int // the user that wrote this article
Text string
}
Articles are created by Users.
type Comment ¶
type Comment struct {
Id int
Created time.Time
ArticleId int // the article that this comment is for
Text string
}
Comments are written for Articles.
type Db ¶
type Db interface {
DriverName() string
Exec(sqls ...string)
InsertUsers(insertSql string, users []User)
InsertArticles(insertSql string, articles []Article)
InsertComments(insertSql string, comments []Comment)
FindUsers(querySql string) []User
FindUsersArticlesComments(querySql string) ([]User, []Article, []Comment)
Close()
}
Db is the database interface.
type SqlDb ¶
type SqlDb struct {
// contains filtered or unexported fields
}
SqlDb is a Db implementation that uses database/sql package.
func (*SqlDb) DriverName ¶
func (*SqlDb) FindArticles ¶
func (*SqlDb) FindUsersArticlesComments ¶
func (*SqlDb) InsertArticles ¶
func (*SqlDb) InsertComments ¶
func (*SqlDb) InsertUsers ¶
Click to show internal directories.
Click to hide internal directories.