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

onMissing option doesn't work with nested objects #206

Open trevore-q4 opened 2 years ago

trevore-q4 commented 2 years ago

I have an object like:

class Metadata {
  @attribute()
  valueA?: string;

  @attribute()
  valueB?: string;
}

@table("documents")
class Document {
  @hashKey()
  key: string;

  @attribute({ memberType: embed(Metadata) })
  metadata: Metadata;
}

Using DataMapper.update with the onMissing option set to skip, if I try to update a single property in the nested object, all missing properties are removed, not skipped as the option would suggest.

Sample code:

const doc = new Document();
doc.key = "<hashKey>";
doc.metadata = new Metadata();
doc.metadata.valueB = "new value";
const dataMapper = new DataMapper();
dataMapper.update(doc, { onMissing: 'skip' });

Result is that valueA gets stripped from the document.

LucasMcLBuilt commented 2 years ago

I have the same problem. This is pretty much a show stopper for me. I need to be able to patch nested objects.

drewahyatt commented 2 years ago

Same issue here. ORM that does not update an entire record must fix

LucasMcLBuilt commented 2 years ago

https://github.com/awslabs/dynamodb-data-mapper-js/issues/201

It appears this project isn't being maintained any more. So don't hold your breath for this feature.