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
817 stars 106 forks source link

defaultProvider does not work on subclass #132

Closed skrosoft closed 5 years ago

skrosoft commented 5 years ago

Hello,

I have a problem with the defaultProvider that doesnt work on sub-class @attribute({defaultProvider: () => 200})

Here is my code. I could be a bug, right?

import ... from '@aws/dynamodb-data-mapper-annotations';

@table('payment_service_provider')
export class PaymentServiceProvider {
    @autoGeneratedHashKey()
    id: string;

    ...

    @attribute()
    apiEndpoints?: PaymentServiceProviderApiEndpoints;

    ...
}

class PaymentServiceProviderApiEndpoints{
    leadsCreate: ApiEndpoint;
}

class ApiEndpoint{

    @attribute()
    url: string;

    @attribute({defaultProvider: () => 200})
    expectedStatusCode: number;
}

Vincent

skrosoft commented 5 years ago

It seems it was because embed() was missing:

@attribute({memberType: embed(PaymentServiceProviderApiEndpoints)})