-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.go
50 lines (36 loc) · 1.01 KB
/
data.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
47
48
49
50
package main
import (
"fmt"
"gopkg.in/mgo.v2"
)
var dbSession *mgo.Session
func initializeDatastore() bool {
var mds = getMongoDatasource()
var err error
dbSession, err = mgo.Dial(mds)
if err != nil {
fmt.Printf("Could not initialize persistence store, exitting: %s\n", err)
return false
}
return true
}
func PersistUSDAFoodWeight(record USDAFoodWeight) error {
err := dbSession.DB("nutdata").C("foodWeight").Insert(record)
if err != nil {
return fmt.Errorf("Error persisting Food Weight %s: %s", record.FoodID, err)
}
return nil
}
func PersistUSDAFoodDesc(record USDAFoodDesc) error {
err := dbSession.DB("nutdata").C("foodDesc").Insert(record)
if err != nil {
return fmt.Errorf("Error persisting Food Desc: %s", record.FoodID, err)
}
return nil
}
func IndexUSDAFoodWeight(record USDAFoodWeight) error {
return fmt.Errorf("Error indexing Food Weight %s", record.FoodID)
}
func IndexUSDAFoodDesc(record USDAFoodDesc) error {
return fmt.Errorf("Error indexing Food Desc %s", record.FoodID)
}