Add SQLite support
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
|
||||
"github.com/localhots/cmdui/backend/config"
|
||||
|
||||
+3
-10
@@ -127,16 +127,9 @@ func (r *Job) Create() error {
|
||||
r.State = string(JobStateCreated)
|
||||
|
||||
_, err := db.NamedExec(`
|
||||
INSERT INTO jobs
|
||||
SET
|
||||
id = :id,
|
||||
command = :command,
|
||||
args = :args,
|
||||
flags = :flags,
|
||||
user_id = :user_id,
|
||||
state = :state,
|
||||
created_at = :created_at
|
||||
`, r)
|
||||
INSERT INTO jobs (id, command, args, flags, user_id, state, created_at)
|
||||
VALUES (:id, :command, :args, :flags, :user_id, :state, :created_at)
|
||||
`, r)
|
||||
if err != nil {
|
||||
return errors.Annotate(err, "Failed to create a job")
|
||||
}
|
||||
|
||||
@@ -42,13 +42,9 @@ func FindSession(id string) (*Session, error) {
|
||||
|
||||
func (s Session) Create() error {
|
||||
_, err := db.NamedExec(`
|
||||
INSERT INTO sessions
|
||||
SET
|
||||
id = :id,
|
||||
user_id = :user_id,
|
||||
created_at = :created_at,
|
||||
expires_at = :expires_at
|
||||
`, s)
|
||||
INSERT INTO sessions (id, user_id, created_at, expires_at)
|
||||
VALUES (:id, :user_id, :created_at, :expires_at)
|
||||
`, s)
|
||||
if err != nil {
|
||||
return errors.Annotate(err, "Failed to create a session")
|
||||
}
|
||||
|
||||
+2
-7
@@ -71,13 +71,8 @@ func findUser(query string, args ...interface{}) (*User, error) {
|
||||
|
||||
func (u User) Create() error {
|
||||
_, err := db.NamedExec(`
|
||||
INSERT INTO users
|
||||
SET
|
||||
id = :id,
|
||||
github_id = :github_id,
|
||||
github_login = :github_login,
|
||||
github_name = :github_name,
|
||||
github_picture = :github_picture
|
||||
INSERT INTO users (id, github_id, github_login, github_name, github_picture)
|
||||
VALUES (:id, :github_id, :github_login, :github_name, :github_picture)
|
||||
`, u)
|
||||
if err != nil {
|
||||
return errors.Annotate(err, "Failed to create a user")
|
||||
|
||||
Reference in New Issue
Block a user