Skip to content

Conversation

@0x009922
Copy link
Contributor

Closes #213

  • Makes use of selectors and predicates way more intuitive and less verbose.
  • Matches the look of Rust API

Before:

await client.find
  .accounts({
    predicate: dm.CompoundPredicate.Or<dm.AccountProjectionPredicate>(
      dm.CompoundPredicate.Atom(dm.AccountProjectionPredicate.Id.Domain.Name.Atom.Contains('cert')),
      dm.CompoundPredicate.Atom(
        dm.AccountProjectionPredicate.Id.Signatory.Atom.Equals(bob.publicKey()),
      ),
    ),
    selector: dm.AccountProjectionSelector.Metadata.Key({
      key: new dm.Name('alias'),
      projection: { kind: 'Atom' },
    }),
  })
  .executeAll()

After:

await client.find
  .accounts()
  .filterWith((account) =>
    dm.CompoundPredicate.Or(
      dm.CompoundPredicate.Atom(
        account.id.domain.name.contains('cert'),
      ),
      dm.CompoundPredicate.Atom(
        account.id.signatory.equals(bob.publicKey()),
      ),
    )
  )
  .selectWith((account) => account.metadata.key(new dm.Name('alias')))
  .executeAll()

Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
@0x009922 0x009922 self-assigned this Mar 11, 2025
@0x009922 0x009922 marked this pull request as ready for review March 11, 2025 07:51
@0x009922 0x009922 merged commit eff7f60 into hyperledger-iroha:main Mar 11, 2025
5 checks passed
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

Successfully merging this pull request may close these issues.

Prototype-based selectors and predicates

1 participant