Skip to content

Best practices and tips

Performance considerations

  1. Use server-side operations: Prefer CDT operations over read-modify-write patterns.
  2. Batch operations: Combine multiple operations in a single Operate() call.
  3. Choose appropriate policies: Use UNORDERED when order doesn’t matter for better performance.
  4. Limit nested depth: Deep nesting can impact performance.

Type assertions for results

Results from CDT operations may need type assertions:

results := record.Bins["profile"].(as.OpResults)
// String values
name := results[0].(string)
// Integer values (server returns as int)
age := results[0].(int)
// Float values
price := results[0].(float64)
// Boolean values
active := results[0].(bool)
// Map values
profile := results[0].(map[any]any)
// List values
items := results[0].([]any)
// MapPair for KEY_VALUE return type
pair := results[0].(as.MapPair)
Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?