Map operations
Example: user with nested address map
// Store nested structureuserData := map[any]any{ "name": "John Doe", "address": map[string]any{ "street": "123 Main St", "city": "San Francisco", "zip": "94102", },}
key, _ := as.NewKey("app", "users", "user123")_, err := client.Operate(nil, key, as.MapPutItemsOp(as.DefaultMapPolicy(), "user", userData),)
// Get nested cityctx := []*as.CDTContext{ as.CtxMapKey(as.StringValue("address")),}
record, err := client.Operate(nil, key, as.MapGetByKeyOp("user", "city", as.MapReturnType.VALUE, ctx...),)
results := record.Bins["user"].(map[any]any)city := results["city"].(string)fmt.Println("City:", city) // Output: City: San FranciscoExample: multi-level configuration
// Store nested configurationconfig := map[any]any{ "database": map[string]any{ "primary": map[string]any{ "host": "db1.example.com", "port": 3306, }, "replica": map[string]any{ "host": "db2.example.com", "port": 3306, }, },}
key, _ := as.NewKey("app", "config", "production")_, err := client.Operate(nil, key, as.MapPutItemsOp(as.DefaultMapPolicy(), "config", config),)
// Get primary database hostctx := []*as.CDTContext{ as.CtxMapKey(as.StringValue("database")), as.CtxMapKey(as.StringValue("primary")),}
record, err := client.Operate(nil, key, as.MapGetByKeyOp("config", "host", as.MapReturnType.VALUE, ctx...),)
host := record.Bins["config"].(string)fmt.Println("Primary DB host:", host)