forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lower_third.go
46 lines (38 loc) · 1.26 KB
/
lower_third.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2014 Team 254. All Rights Reserved.
// Author: [email protected] (Patrick Fairbank)
//
// Model and datastore CRUD methods for the text on a lower third slide.
package main
type LowerThird struct {
Id int
TopText string
BottomText string
}
func (database *Database) CreateLowerThird(lowerThird *LowerThird) error {
return database.lowerThirdMap.Insert(lowerThird)
}
func (database *Database) GetLowerThirdById(id int) (*LowerThird, error) {
lowerThird := new(LowerThird)
err := database.lowerThirdMap.Get(lowerThird, id)
if err != nil && err.Error() == "sql: no rows in result set" {
lowerThird = nil
err = nil
}
return lowerThird, err
}
func (database *Database) SaveLowerThird(lowerThird *LowerThird) error {
_, err := database.lowerThirdMap.Update(lowerThird)
return err
}
func (database *Database) DeleteLowerThird(lowerThird *LowerThird) error {
_, err := database.lowerThirdMap.Delete(lowerThird)
return err
}
func (database *Database) TruncateLowerThirds() error {
return database.lowerThirdMap.TruncateTables()
}
func (database *Database) GetAllLowerThirds() ([]LowerThird, error) {
var lowerThirds []LowerThird
err := database.teamMap.Select(&lowerThirds, "SELECT * FROM lower_thirds ORDER BY id")
return lowerThirds, err
}