dynamo-easy icon indicating copy to clipboard operation
dynamo-easy copied to clipboard

Cannot save empty nested array or object.

Open kdby-io opened this issue 5 years ago • 1 comments

Describe the bug

When a nested array or object is empty, it is ignored on saving.

To Reproduce

@Model()
export class A{
  @PartitionKey()
  id: string

  @CollectionProperty({ sorted: true, itemType: B })
  bs: B[]
}

@Model()
export class B {
  props: { [key: string]: any };
}

const a1: A = {
  id: uuid(),
  bs: []
}
const a2: A = {
  id: uuid(),
  bs: [{
    props: {
      hello: {},
      world: 'a2'
    }
  }]
}
const a3: A = {
  id: uuid(),
  bs: [{
    props: {
      hello: {
        arr: []
      },
      world: 'a3'
    }
  }]
}

await this.store.put(a1).exec();  // { id: ..., bs: [] }
await this.store.put(a2).exec();  // { id: ..., bs: [{ props: { world: 'a2' } }] }
await this.store.put(a3).exec();  // { id: ..., bs: [{ props: { world: 'a3' } }] }

Expected behavior

a nested empty array or object can be saved.

kdby-io avatar Jul 06 '20 01:07 kdby-io

@kdby-io A fix for this is released on the next stream -> ^8.0.0-next.7 https://github.com/shiftcode/dynamo-easy/pull/431#issuecomment-2876942269

michaelwittwer avatar May 13 '25 15:05 michaelwittwer