---
title: "Map operations"
description: "Learn how to perform nested map operations using the Aerospike Go client with practical Put and Get examples."
---

# Map operations

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

#### Example: user with nested address map

```go
// Store nested structure

userData := map[any]any{

    "name": "John Doe",

    "address": map[string]any{

        "street": "123 Main St",

        "city":   "San Francisco",

        "zip":    "94102",

    },

}

key, _ := as.NewKey("app", "users", "user123")

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

    as.MapPutItemsOp(as.DefaultMapPolicy(), "user", userData),

)

// Get nested city

ctx := []*as.CDTContext{

    as.CtxMapKey(as.StringValue("address")),

}

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

    as.MapGetByKeyOp("user", "city", as.MapReturnType.VALUE, ctx...),

)

results := record.Bins["user"].(map[any]any)

city := results["city"].(string)

fmt.Println("City:", city)  // Output: City: San Francisco
```

#### Example: multi-level configuration

```go
// Store nested configuration

config := map[any]any{

    "database": map[string]any{

        "primary": map[string]any{

            "host": "db1.example.com",

            "port": 3306,

        },

        "replica": map[string]any{

            "host": "db2.example.com",

            "port": 3306,

        },

    },

}

key, _ := as.NewKey("app", "config", "production")

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

    as.MapPutItemsOp(as.DefaultMapPolicy(), "config", config),

)

// Get primary database host

ctx := []*as.CDTContext{

    as.CtxMapKey(as.StringValue("database")),

    as.CtxMapKey(as.StringValue("primary")),

}

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

    as.MapGetByKeyOp("config", "host", as.MapReturnType.VALUE, ctx...),

)

host := record.Bins["config"].(string)

fmt.Println("Primary DB host:", host)
```