# CRUD List contained in a map

**URL:** <https://discuss.aerospike.com/t/crud-list-contained-in-a-map/6886>\
**Category:** Node.js Client\
**Created:** [December 5, 2019, 10:30am UTC](https://discuss.aerospike.com/t/crud-list-contained-in-a-map/6886 "2019-12-05T10:30:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xfankit](https://avatars.discourse-cdn.com/v4/letter/x/a5b964/32.png) [@xfankit](https://discuss.aerospike.com/u/xfankit)\
**Post date:** [December 5, 2019, 10:30am UTC](https://discuss.aerospike.com/t/crud-list-contained-in-a-map/6886/1 "2019-12-05T10:30:11Z")

</div>

I have a data structure something like this : { id : address : [{ id : }, { id : }] } So how can i achieve this in aerospike. Should i use the List data structure or and suggestion regarding this.

Thank you.

---

<div class="post-metadata">

**Author:** ![Jan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/jan/32/1124_2.png) [@Jan](https://discuss.aerospike.com/u/Jan)\
**Post date:** [December 5, 2019, 3:10pm UTC](https://discuss.aerospike.com/t/crud-list-contained-in-a-map/6886/2 "2019-12-05T15:10:19Z")

</div>

This question really belongs more under the Data Modeling topic, since it’s not specific to the Node.js client.

A bit more information about your use case and the typical query patterns would also be useful. I.e. you have an `id` field for each entry in your list of addresses. Would you even need to lookup a specific address by it’s ID? In that case it would be better to model the `address` bin as a map, where the keys of the map are the IDs of your addresses, and the values of the map are also each nested maps with the details of the address.

---

<div class="post-metadata">

**Author:** ![xfankit](https://avatars.discourse-cdn.com/v4/letter/x/a5b964/32.png) [@xfankit](https://discuss.aerospike.com/u/xfankit)\
**Post date:** [December 6, 2019, 7:22am UTC](https://discuss.aerospike.com/t/crud-list-contained-in-a-map/6886/3 "2019-12-06T07:22:08Z")

</div>

> [@Jan](#):
>
> nd the values of the map

Hello Jan, Thanks for the response. My use case is i have to save users and its related address. And perform CRUD operations on address. My understanding of your response is the below JSON. If you could verify that, it would be of great help. And if it is correct how will i manage update operations on address because of the dynamic nature keys in the address object. { id: “userid”, address: { aId: {detail }, a2Id: { detail } } }

---

<div class="post-metadata">

**Author:** ![Jan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/jan/32/1124_2.png) [@Jan](https://discuss.aerospike.com/u/Jan)\
**Post date:** [December 6, 2019, 7:47am UTC](https://discuss.aerospike.com/t/crud-list-contained-in-a-map/6886/4 "2019-12-06T07:47:42Z")

</div>

Yes, based on your description of your use case, that seems like a good way to structure your data in Aerospike.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/system/32/2274_2.png) [@system](https://discuss.aerospike.com/u/system)\
**Post date:** [December 12, 2019, 7:47am UTC](https://discuss.aerospike.com/t/crud-list-contained-in-a-map/6886/5 "2019-12-12T07:47:45Z")

</div>

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.
