Modify operations
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
Use the Aerospike Go client to change entries in a map bin on the server. Increment or decrement a number, remove by key or value, or clear the map. Each operation runs through Operate(), so you don’t read and rewrite the map in your application. Increment and decrement are atomic.
MapIncrementOp / MapDecrementOp: increment/decrement values
Atomically increments or decrements a numeric value in a map.
// Increment a counter_, err := client.Operate(nil, key, as.MapIncrementOp(as.DefaultMapPolicy(), "counters", "views", 1),)
// Decrement inventory_, err := client.Operate(nil, key, as.MapDecrementOp(as.DefaultMapPolicy(), "inventory", "item123", 5),)MapRemoveByKeyOp: remove by key
Removes a key-value pair from the map.
// Remove a key_, err := client.Operate(nil, key, as.MapRemoveByKeyOp("profile", "oldField", as.MapReturnType.NONE),)
// Remove and get the removed valuerecord, err := client.Operate(nil, key, as.MapRemoveByKeyOp("profile", "tempData", as.MapReturnType.VALUE),)
removedValue := record.Bins["profile"].(string) // Value that was removedMapRemoveByValueOp: remove by value
Removes all key-value pairs that have a specific value.
// Remove all items with value "inactive"_, err := client.Operate(nil, key, as.MapRemoveByValueOp("status", "inactive", as.MapReturnType.KEY),)MapClearOp: clear all items
Removes all items from the map.
// Clear entire map_, err := client.Operate(nil, key, as.MapClearOp("profile"),)Next steps
- Map creation and setup
- Map get operations
- Map range operations
- Quick reference: return types for map operations