When using Operate(), the way results are returned in record.Bins depends on how many operations target the same bin:
- Single operation on a bin: The result is returned directly as its underlying type (e.g.,
string, int, []any). It is not wrapped in OpResults. - Multiple operations on the same bin: The results are wrapped in an
as.OpResults type, which is a slice ([]interface{}). The elements in the slice correspond to the operations in the order they were provided. - Operations on different bins: Each bin returns its value directly, regardless of how many total operations were performed in the call.
Note: If a single operation returns a slice (like MapGetByValueOp with KEY return type), it is stored directly as []any, not wrapped in OpResults.
// Example: Multiple Operations on the SAME bin (Returns OpResults)
record, err := client.Operate(nil, key,
as.MapGetByKeyOp("profile", "name", as.MapReturnType.VALUE),
as.MapGetByKeyOp("profile", "age", as.MapReturnType.VALUE),
)
results := record.Bins["profile"].(as.OpResults) // Wrapped in OpResults
name := results[0].(string) // First operation
age := results[1].(int) // Second operation
// Example: Single Operation on a bin (Returns Value Directly)
record, err := client.Operate(nil, key,
as.MapGetByKeyOp("profile", "name", as.MapReturnType.VALUE),
)
name := record.Bins["profile"].(string) // Direct value, NOT OpResults
// Example: Operations on DIFFERENT bins (Each Returns Directly)
record, err := client.Operate(nil, key,
as.MapGetByKeyOp("profile", "name", as.MapReturnType.VALUE),
as.MapGetByKeyOp("orders", "count", as.MapReturnType.VALUE),
)
name := record.Bins["profile"].(string) // Direct value
count := record.Bins["orders"].(int) // Direct value