Map datatype
Map datatype should be implemented in similar way as well as Set data type, but store key value pairs. Key and value can be only simple data type (not a collection): String, Number or Blob. So actually we have 9 new datatypes: SSM, SNM, SBM, NSM, NNM, SBM, BSM, BNM, BBM. firs letter specifies key type, second - value type and the third one - M shows us that it is actually Map data type.
So bellow is the CreateTable request example with map data type attribute defined:
{
"table_name": "demo_table",
"attribute_
{
},
{
},
{
}
],
"key_schema": [
{
},
{
}
]
}
As well as Set data type you can't use attributes of Map data type for keys and indices. You can only store data of Map data type
Now I will show you how to put item with Map data type:
{
"item": {
"hash_key": {
"N": "1"
},
"S": "d"
},
}
},
}
}
}
}
It is Put request example. Hopefully Json format is aimed to specify keys and it values so Map attribute value format is simple json.
Here you can see that we set ss_map_value predefined attribute of SSM type (attribute specified in CreateTable request example) and ns_map_value dynamically defined attribute (was absent in table schema). Dynamically created attributes are aslo implemented And you can document it too
Aslo UpdateItem request supports Map data types, (PUT, ADD and DELETE operations). PUT rewrites all map (like PutItem request), ADD - adds new items to existed map or rewrites specified keys and leave not specified non touched, DELETE - removes specified keys from map
Here is example of UpdateItem with ADD action:
{
"attribute_
}
}
},
}
}
}
},
"key": {
"hash_key": {
"N": "1"
},
"S": "d"
}
}
}
And with DELETE action:
{
"attribute_
]
}
}
},
"key": {
"hash_key": {
"N": "1"
},
"S": "d"
}
}
}
Blueprint information
- Status:
- Complete
- Approver:
- None
- Priority:
- Medium
- Drafter:
- Ilya Sviridov
- Direction:
- Approved
- Assignee:
- Dmitriy Ukhlov
- Definition:
- New
- Series goal:
- Accepted for juno
- Implementation:
- Implemented
- Milestone target:
- juno-3
- Started by
- Ilya Sviridov
- Completed by
- Ilya Sviridov