Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot save empty nested array or object. #318

Open
kdby-io opened this issue Jul 6, 2020 · 0 comments
Open

Cannot save empty nested array or object. #318

kdby-io opened this issue Jul 6, 2020 · 0 comments

Comments

@kdby-io
Copy link

kdby-io commented Jul 6, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant