Skip to content
This repository was archived by the owner on Jun 19, 2023. It is now read-only.

Can a field be configured to always update on save?Β #81

Open
@LucasBadico

Description

@LucasBadico

I'm using the mapper with this schema based aprouch.

Object.defineProperties(MyDomainModel.prototype, {
    [DynamoDbSchema]: {
        value: {
            phone: {
                type: 'Dictionary',
                memberType: embed(Phone)
            },
        },
    },
}); 

createdAt and updatedAt

I see that for the attr createdAt I can send a defaultProvider instruction with new Date(). In the same way to the v4 for generating a uuid.

There is a way to send a instruction for the mapper change the attr updatedAt every time? Like a forced provider.

Object.defineProperties(MyDomainModel.prototype, {
    [DynamoDbSchema]: {
        value: {
            createdAt: {
                type: 'Date',
                defaultProvider: () => new Date()
            },
        },
    },
}); 

version attribute

class MyDomainClass {
    @autoGeneratedHashKey()
    id: string;

    @rangeKey({defaultProvider: () => new Date()})
    createdAt: Date;

    @versionAttribute()
    version: number;
}

How to use this version attribute in the Object.defineProperties way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestNew feature or enhancement. May require GitHub community feedback.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions