[couchdb] Pobranie wszystkich danych z dokuemntu
This commit is contained in:
parent
aef835e620
commit
53ec7d5178
@ -105,36 +105,34 @@ func getAllDoc() {
|
|||||||
keys := reflect.ValueOf(generic).MapKeys()
|
keys := reflect.ValueOf(generic).MapKeys()
|
||||||
fmt.Println("KEYS: ", keys)
|
fmt.Println("KEYS: ", keys)
|
||||||
|
|
||||||
|
// allCards := []Card{}
|
||||||
|
|
||||||
for k, v := range generic {
|
for k, v := range generic {
|
||||||
if k == "rows" {
|
if k == "rows" {
|
||||||
switch val := v.(type) {
|
switch val := v.(type) {
|
||||||
// case string:
|
|
||||||
// fmt.Println(k, "is string", val)
|
|
||||||
// case int:
|
|
||||||
// fmt.Println(k, "is int", val)
|
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
fmt.Println(k, "is an array")
|
fmt.Println(k, "is an array")
|
||||||
for _, v := range val {
|
for _, v := range val {
|
||||||
// fmt.Println(v) //, i)
|
var tmpCard Card
|
||||||
// fmt.Println(reflect.TypeOf(v))
|
|
||||||
// fmt.Println(i)
|
|
||||||
mResult := v.(map[string]interface{})
|
mResult := v.(map[string]interface{})
|
||||||
// fmt.Println(mResult["doc"])
|
|
||||||
// fmt.Println(reflect.TypeOf(mResult["doc"]))
|
|
||||||
|
|
||||||
mResult2 := mResult["doc"].(map[string]interface{})
|
mResult2 := mResult["doc"].(map[string]interface{})
|
||||||
// fmt.Println(reflect.TypeOf(mResult2))
|
|
||||||
fmt.Println(mResult2["Text"])
|
fmt.Println(mResult2["Text"])
|
||||||
|
fmt.Println(reflect.TypeOf(mResult2["Text"]))
|
||||||
|
tmpCard.Text = mResult2["Text"].(string)
|
||||||
fmt.Println(mResult2["Timestamp"])
|
fmt.Println(mResult2["Timestamp"])
|
||||||
fmt.Println(mResult2["_id"])
|
tmpCard.Timestamp = mResult2["Timestamp"].(float64)
|
||||||
fmt.Println(mResult2["blank"])
|
|
||||||
|
|
||||||
// mResult2 := mResult.(map[string]interface{})
|
fmt.Println(mResult2["_id"])
|
||||||
// fmt.Println(mResult2["Timestamp"])
|
tmpCard.Id = mResult2["_id"].(string)
|
||||||
|
|
||||||
|
fmt.Println(mResult2["blank"])
|
||||||
|
tmpCard.Blank = int(mResult2["blank"].(float64))
|
||||||
|
|
||||||
|
fmt.Println(mResult2["isquestion"])
|
||||||
|
tmpCard.IsQuestion = mResult2["isquestion"].(bool)
|
||||||
|
|
||||||
}
|
}
|
||||||
// default:
|
|
||||||
// fmt.Println(k, "is unknown type")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,9 @@ type User struct {
|
|||||||
*/
|
*/
|
||||||
type Card struct {
|
type Card struct {
|
||||||
couchdb.Document
|
couchdb.Document
|
||||||
Id int `json:"id" binding:"required"`
|
Id string `json:"id" binding:"required"`
|
||||||
IsQuestion bool `json:"isQuestion"` //0 karta pytanie, 1 karta odpowiedź
|
IsQuestion bool `json:"isQuestion"` //0 karta pytanie, 1 karta odpowiedź
|
||||||
Blank int `json:"blank" binding:"required"` //ile kart odpowiedzi na pytanie
|
Blank int `json:"blank" binding:"required"` //ile kart odpowiedzi na pytanie
|
||||||
Text string `json:"text" binding:"required"` // podłoga to luka
|
Text string `json:"text" binding:"required"` // podłoga to luka
|
||||||
|
Timestamp float64
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user