25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
573 B
25 lines
573 B
package models
|
|
|
|
import (
|
|
"github.com/Unknwon/com"
|
|
"os"
|
|
"path"
|
|
"github.com/astaxie/beego/orm"
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
const(
|
|
_DB_NAME = "data/beeblog.db"
|
|
_SQLITE3_DRIVER = "sqlite3"
|
|
)
|
|
|
|
func RegistDB() {
|
|
if !com.IsExist(_DB_NAME){
|
|
os.MkdirAll(path.Dir(_DB_NAME),os.ModePerm)
|
|
os.Create(_DB_NAME)
|
|
}
|
|
//orm.RegisterModel(new(Attachment),new(Topic))
|
|
orm.RegisterModel(new(Attachment),new(User),new(Blog),new(NLabel),new(Note),new(NoteColl))
|
|
orm.RegisterDriver(_SQLITE3_DRIVER,orm.DRSqlite)
|
|
orm.RegisterDataBase("default",_SQLITE3_DRIVER,_DB_NAME,10)
|
|
}
|