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

Querying for tags whose content is an array #1145

Closed
genaris opened this issue Dec 7, 2022 · 2 comments
Closed

Querying for tags whose content is an array #1145

genaris opened this issue Dec 7, 2022 · 2 comments

Comments

@genaris
Copy link
Contributor

genaris commented Dec 7, 2022

When merging #994 we set the possibility of adding multiple connection types in order to give more flexibility to the application to categorize the different connections. This is implemented by setting the "connectionType" tag as a string array.

My question is: is there a way to do an efficient query for a tag like that if it contains more than a single element? Let's say I have a connection whose connectionType tag is [ 'Mediator', 'Issuer' ] and I want to search for all connections whose connectionType tag contains the type 'Issuer'. Is it possible to do so with Indy and Askar WQL?

@TimoGlastra
Copy link
Contributor

Yes! I think you can just do the following:

  await faberAgent.connections.findAllByQuery({
    connectionType: ['a', 'b'],
  })

this will translate to:

    {
      'connectionType:a': '1',
      'connectionType:b': '1',
      '$and': undefined,
      '$or': undefined,
      '$not': undefined
    }

Indy doesn't natively support array tags, but we achieve it by having the key:value as the tag name.


Had to make two slight adjustions:

  1. Add DefaultConnectionTags & CustomConnectionTags as return type for the getTags in ConnectionRecord, I think there's something wrong with the inference of findByQuery.
  2. Had to change the type of the connectionType tag to Array<ConnectionType | string> as [ConnectionType | string] doesn't work and means an array with one entry

@genaris
Copy link
Contributor Author

genaris commented Dec 8, 2022

Great! Thanks for the explanation. I've added these adjustments to #1147 so we can query connection types properly.

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

2 participants