Nested CDT operations
Nested operations allow you to work with Maps and Lists that contain other Maps and Lists, creating complex data structures.
Understanding CDT context
CDT context specifies the path to a nested map or list within a data structure. You can chain contexts to navigate deep into nested structures.
Context types:
CtxMapKey(key): Navigate to a map value by key.CtxListIndex(index): Navigate to a list item by index.CtxMapRank(rank): Navigate to a map value by rank.CtxListRank(rank): Navigate to a list item by rank.
Example structure:
bin = { "user123": { "profile": { "name": "John", "address": { "city": "SF", "zip": "94102" } }, "orders": [ {"id": "ord1", "total": 100}, {"id": "ord2", "total": 200} ] }}To access zip in the nested address map:
ctx := []*as.CDTContext{ as.CtxMapKey(as.StringValue("user123")), as.CtxMapKey(as.StringValue("profile")), as.CtxMapKey(as.StringValue("address")),}
record, err := client.Operate(nil, key, as.MapGetByKeyOp("data", "zip", as.MapReturnType.VALUE, ctx...),)