working on rethinkdb stuff

This commit is contained in:
Torkel Ödegaard
2014-08-21 22:09:48 +02:00
parent d8dca20332
commit 07d8b542bf
10 changed files with 437 additions and 286 deletions
+23 -16
View File
@@ -3,20 +3,39 @@ package models
import (
"encoding/json"
"io"
"time"
)
type Dashboard struct {
Data map[string]interface{}
Id string `gorethink:"id,omitempty"`
AccountId string
LastModifiedByUserId string
LastModifiedByDate time.Time
CreatedDate time.Time
Title string
Tags []string
Data map[string]interface{}
}
type UserContext struct {
UserId string
AccountId string
}
type SearchResult struct {
Type string `json:"title"`
Id string `json:"id"`
Title string `json:"title"`
}
func NewDashboard(title string) *Dashboard {
dash := &Dashboard{}
dash.Id = ""
dash.AccountId = "test"
dash.LastModifiedByDate = time.Now()
dash.CreatedDate = time.Now()
dash.LastModifiedByUserId = "123"
dash.Title = title
dash.Data = make(map[string]interface{})
dash.Data["title"] = title
@@ -31,23 +50,11 @@ func NewFromJson(reader io.Reader) (*Dashboard, error) {
return nil, err
}
dash.Title = dash.Data["title"].(string)
return dash, nil
}
/*type DashboardServices struct {
}
type DashboardServicesFilter struct {
}
type DashboardServicesFilterTime struct {
From string To string
}*/
func (dash *Dashboard) GetString(prop string) string {
return dash.Data[prop].(string)
}
func (dash *Dashboard) Title() string {
return dash.GetString("title")
}