Progres on move to sql from rethinkdb

This commit is contained in:
Torkel Ödegaard
2014-11-20 12:11:07 +01:00
parent 9b68911d00
commit eb2c078898
13 changed files with 118 additions and 62 deletions
+16 -13
View File
@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"errors"
"io"
"regexp"
"strings"
@@ -9,19 +10,24 @@ import (
)
var (
GetDashboard func(slug string, accountId int) (*Dashboard, error)
GetDashboard func(slug string, accountId int64) (*Dashboard, error)
SaveDashboard func(dash *Dashboard) error
DeleteDashboard func(slug string, accountId int) error
SearchQuery func(query string, acccountId int) ([]*SearchResult, error)
DeleteDashboard func(slug string, accountId int64) error
SearchQuery func(query string, acccountId int64) ([]*SearchResult, error)
)
// Typed errors
var (
ErrDashboardNotFound = errors.New("Account not found")
)
type Dashboard struct {
Id string `gorethink:"id,omitempty"`
Slug string
AccountId int
LastModifiedByUserId string
LastModifiedByDate time.Time
CreatedDate time.Time
Id int64
Slug string `xorm:"index(IX_AccountIdSlug)"`
AccountId int64 `xorm:"index(IX_AccountIdSlug)"`
Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"UPDATED"`
Title string
Tags []string
@@ -36,10 +42,7 @@ type SearchResult struct {
func NewDashboard(title string) *Dashboard {
dash := &Dashboard{}
dash.Id = ""
dash.LastModifiedByDate = time.Now()
dash.CreatedDate = time.Now()
dash.LastModifiedByUserId = "123"
dash.Id = 0
dash.Data = make(map[string]interface{})
dash.Data["title"] = title
dash.Title = title