Torkel Ödegaard 8 anni fa
parent
commit
998f04e1e8
2 ha cambiato i file con 42 aggiunte e 0 eliminazioni
  1. 18 0
      pkg/models/test_data.go
  2. 24 0
      pkg/services/sqlstore/sql_test_data.go

+ 18 - 0
pkg/models/test_data.go

@@ -0,0 +1,18 @@
+package models
+
+import "time"
+
+type InsertSqlTestDataCommand struct {
+}
+
+type SqlTestData struct {
+	Id            int64
+	Metric1       string
+	Metric2       string
+	ValueBigInt   int64
+	ValueDouble   float64
+	ValueInt      int
+	TimeEpoch     int64
+	TimeDateTime  time.Time
+	TimeTimeStamp time.Time
+}

+ 24 - 0
pkg/services/sqlstore/sql_test_data.go

@@ -0,0 +1,24 @@
+package sqlstore
+
+import (
+	"github.com/grafana/grafana/pkg/bus"
+	m "github.com/grafana/grafana/pkg/models"
+)
+
+func init() {
+	bus.AddHandler("sql", InsertSqlTestData)
+}
+
+func InsertSqlTestData(cmd *m.InsertSqlTestDataCommand) error {
+	return inTransaction2(func(sess *session) error {
+
+		// create user
+		user := &m.SqlTestData{}
+
+		if _, err := sess.Insert(user); err != nil {
+			return err
+		}
+
+		return nil
+	})
+}