From 270b3e0d1f61f65e1bc42ee72c7e6724303a4646 Mon Sep 17 00:00:00 2001 From: Aleksandr Sokolovskii Date: Mon, 7 May 2018 18:20:54 +0300 Subject: [PATCH] added more examples how to work with Complex Object --- README.md | 10 ++++++++-- examples_test.go | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 33922ad..1ffdbec 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ err := c.CachePut("CacheGet", false, "Time", ToTime(t)) // ToTime() converts tim t, err = c.CacheGet("CacheGet", false, "Time") // 't' is time.Time (where year=1, month=1 and day=1), you don't need any converting ``` -### Example how to use `Complex Object` type +### Example how to use **Complex Object** type ```go // put complex object @@ -235,7 +235,7 @@ if err := c.CachePut(cache, false, "key3", c2); err != nil { ... // get complex object -v, err := c.CacheGet(cache, false, "key3") +v, err = c.CacheGet(cache, false, "key3") if err != nil { return err } @@ -244,6 +244,12 @@ log.Printf("key=\"%s\", value=\"%#v\"", "key3", c2) v, _ = c2.Get("complexField1") c1 = v.(ignite.ComplexObject) log.Printf("key=\"%s\", value=\"%#v\"", "complexField1", c1) +v, _ = c1.Get("field1") +log.Printf("key=\"%s\", value=\"%s\"", "field1", v) +v, _ = c1.Get("field2") +log.Printf("key=\"%s\", value=%d", "field2", v) +v, _ = c1.Get("field3") +log.Printf("key=\"%s\", value=%t", "field3", v) ``` ### SQL and Scan Queries supported operations diff --git a/examples_test.go b/examples_test.go index 6a1a5e3..75db44b 100644 --- a/examples_test.go +++ b/examples_test.go @@ -157,6 +157,12 @@ func Test_Key_Value(t *testing.T) { v, _ = c2.Get("complexField1") c1 = v.(ignite.ComplexObject) log.Printf("key=\"%s\", value=\"%#v\"", "complexField1", c1) + v, _ = c1.Get("field1") + log.Printf("key=\"%s\", value=\"%s\"", "field1", v) + v, _ = c1.Get("field2") + log.Printf("key=\"%s\", value=%d", "field2", v) + v, _ = c1.Get("field3") + log.Printf("key=\"%s\", value=%t", "field3", v) } func Test_SQL_Queries(t *testing.T) {