talyssonoc/structure

Support Map types with itemType

loweoj opened this issue · 3 comments

It would be really useful to support Map types with itemType. Currently specifying an attribute as type Map results in "attribute.map is not a function" on attribute serialization. Is this something that could be added? If it's just a case of implementing a .map function for Map then that would be relatively trivial?

My use case is storing itemType's ID value as a key on Map.

Thanks!

This would be an excellent feature. We are currently working with DynamoDB and we often bump into cases where we want objects with dynamic property naming. This is an excelent use case for saving dictionaries and/or hashtables.

Both JavaScript and DynamoDB supports this use scenario and it would be a great addition to structure.

As discusses, we're gonna define the key and item type like this:

{
  permissions: {
    type: Map,
    itemType: { key: String, value: Permission }
  }
}

Where the value of key is a property on Permission? e.g.

  permissions: {
    type: Map,
    itemType: { key: 'permissionId', value: Permission }
  }

Or does this mean that keys will be coerced to a string?