restructuring, config and readme
This commit is contained in:
36
backend/internal/model/init.go
Normal file
36
backend/internal/model/init.go
Normal file
@ -0,0 +1,36 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func Init() *gorm.DB {
|
||||
db, err := gorm.Open(sqlite.Open("./blog.db"))
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
db.AutoMigrate(&Post{}, &Comment{})
|
||||
|
||||
db.Save(&Post{
|
||||
ID: 1,
|
||||
Title: "Hello World",
|
||||
TLDR: "introduction to ng-blog",
|
||||
Content: `
|
||||
## Welcome
|
||||
|
||||
This is ng-blog, your simple blog written in Angular and Golang.
|
||||
|
||||
### Login
|
||||
|
||||
The default login is:
|
||||
> Username: admin
|
||||
>
|
||||
> Password: admin
|
||||
`,
|
||||
})
|
||||
|
||||
return db
|
||||
}
|
Reference in New Issue
Block a user