Skip to content

Commit

Permalink
added more examples how to work with Complex Object
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Sokolovskii committed May 7, 2018
1 parent cd1341a commit 270b3e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 270b3e0

Please sign in to comment.