dynamodb-toolbox icon indicating copy to clipboard operation
dynamodb-toolbox copied to clipboard

Map type entity attrs and schemas.

Open edwardgale opened this issue 4 years ago • 1 comments

/Question Interested to know what you will be doing with the TODO regarding object schemas.

For example I am using data and pdata entity level map type attributes. The pdata will be an object that I want projected into the indexes and the data is for pretty much everything else.

Say I want to update the pdata object type with a single attribute and not overwrite the existing record then it would be nice to be able to do a:

const userDbObj = { pk: sub, sk: 'User', pdata: { $set: { 'address.town': 'timbuktoo' } } }
await User.update(userDbObj)

if the 'address' attr has on the pdata object has not already been created then an error is thrown.

Thanks for the lib.

edwardgale avatar May 11 '20 14:05 edwardgale

Hi @edwardgale!

I'll need to look at this to see if it's a library issue or a DDB one (likely the former). If it's the former, then it can be solved in a few different ways, including defaulting paths that don't exist or creating schemas for maps.

Thanks for the note, Jeremy

jeremydaly avatar May 11 '20 14:05 jeremydaly