Modify operations
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
Use the Aerospike Go client to change items in a list bin on the server. Set a value at an index, remove by index or value, pop an item, increment a number, or clear the list. Each operation runs through Operate(), so you don’t read and rewrite the list in your application.
ListSetOp: set value at index
Updates the value at a specific index.
// Update item at index 0_, err := client.Operate(nil, key, as.ListSetOp("tasks", 0, "updated_task"),)ListRemoveOp: remove by index
Removes an item at a specific index.
// Remove first item_, err := client.Operate(nil, key, as.ListRemoveOp("tasks", 0),)
// Remove last item_, err = client.Operate(nil, key, as.ListRemoveOp("tasks", -1),)ListRemoveByValueOp: remove by value
Removes all items with a specific value.
// Remove all occurrences of "completed"_, err := client.Operate(nil, key, as.ListRemoveByValueOp("tasks", "completed", as.ListReturnTypeCount),)ListPopOp: pop item
Removes and returns an item (typically used for queues).
// Pop from front (index 0)record, err := client.Operate(nil, key, as.ListPopOp("queue", 0),)
item := record.Bins["queue"].(string) // Popped itemListIncrementOp: increment numeric value
Increments a numeric value at a specific index.
// Increment counter at index 0_, err := client.Operate(nil, key, as.ListIncrementOp("counters", 0, 1),)ListClearOp: clear all items
Removes all items from the list.
// Clear entire list_, err := client.Operate(nil, key, as.ListClearOp("tasks"),)