Skip to content
This repository was archived by the owner on Feb 23, 2020. It is now read-only.
This repository was archived by the owner on Feb 23, 2020. It is now read-only.

Allow setting defaults in dynamodb items #6

@behos

Description

@behos

Setting default values will allow backwards incompatible migrations for existing items without the need to define optional new fields.

Item stored in ddb:

{
   "id": "1"
   "name": "hello"
}

Current ddb item:

#[derive(DynamoDBItem)]
struct Reviewer {
    #[hash] id: u16,
    name: String
}

You should be able to update the struct with a new field providing a default:

#[derive(DynamoDBItem)]
struct Reviewer {
    #[hash] id: u16,
    name: String,
    #[default=0] reviews: u16
}

When converting from the dynamodb item, if the value is missing, the default should be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions