---
title: "Modify operations"
description: "Guide to modifying Aerospike maps with the Go client, covering increment, decrement, removal, and clear operations."
---

# Modify operations

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

##### `MapIncrementOp` / `MapDecrementOp`: increment/decrement values

Atomically increments or decrements a numeric value in a map.

```go
// 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.

```go
// Remove a key

_, err := client.Operate(nil, key,

    as.MapRemoveByKeyOp("profile", "oldField", as.MapReturnType.NONE),

)

// Remove and get the removed value

record, err := client.Operate(nil, key,

    as.MapRemoveByKeyOp("profile", "tempData", as.MapReturnType.VALUE),

)

removedValue := record.Bins["profile"].(string) // Value that was removed
```

##### `MapRemoveByValueOp`: remove by value

Removes all key-value pairs that have a specific value.

```go
// 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.

```go
// Clear entire map

_, err := client.Operate(nil, key,

    as.MapClearOp("profile"),

)
```