fogfish / dynamo

Generic Golang Key/Value trait for AWS storage services
MIT License
19 stars 5 forks source link

Use Marshall / Unmarshall codes for structs #34

Closed fogfish closed 3 years ago

fogfish commented 3 years ago

Usage of dynamo.ID is an approach to label a struct. However, it brings few practical issues:

  1. It creates deps between core types and aws sdk due to dynamodb.AttributeValue type
  2. Usage of type composition does not make an explicit mapping of core ID to dynamo ID

Consider a following scenario:

type A struct {
  ID curie.IRI `dynamodbav:"-"`
  Name string `dynamodbav:"name,omitempty"`
}

type dbA struct { A }

func (x dbA) MarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error {
   return someHelperFunction(x.A.ID, x)
}

func (x dbA) UnmarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error {
   return someHelperFunction(&x.A.ID, &x)
}

This approach still do not address an issue of linked data

type A struct {
  ID curie.IRI
  Link *curie.IRI
}
fogfish commented 3 years ago

closed by #38