awslabs / dynamodb-data-mapper-js

A schema-based data mapper for Amazon DynamoDB.
https://awslabs.github.io/dynamodb-data-mapper-js/
Apache License 2.0
816 stars 106 forks source link

Custom type marshaller does not get called #200

Closed b-jan closed 3 years ago

b-jan commented 3 years ago

Hello,

I can't figure why my custom marshall function does not get galled. Do I need to specify an option somewhere else in my data mapper to enable Custom types?

In the code below, my input is not logged. All is working as if there was not type 'Custom'...

  @attribute({
    memberType: {
      type: 'Custom',
      marshall(input) {
        console.log(input)
        return VoteValueMarshaller(input)
      },
      unmarshall(persistedValue) {
         console.log(persistedValue)
         return VoteValueUnmarshaller(persistedValue)
      }
    }
  })
  public value: VoteValuePeriod

I used this open source code to code my own.

b-jan commented 3 years ago

memberType: { has not to be here as my attribute is not a list. I just removed it and it worked. Thanks @lucleray