Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Add regex-based "glob" pattern matching to hdk::query #781

Merged
merged 13 commits into from
Dec 22, 2018

Conversation

pjkundert
Copy link
Contributor

@pjkundert pjkundert commented Dec 19, 2018

NOTE: Re-submitted pull request using local branch in holochain repo.

o Change the Holochain query API to accept a Vec<String> vs. String
o If multiple EntryType names (or one with "glob" wildcards) is used,
then produce a GlobSetBuilder matcher to recognize the selected names.

There is no way to get more than a single EntryType via hdk::query.

The primary purpose of this change is to support querying multiple EntryType names in a single hdk::query request. To do this efficiently, a single regex encompassing all of the desired EntryType names is produced.

The globset::GlobSetBuilder is used to do this, and also supports the full "glob" pattern matching on EntryType names. This includes the concept of path-like namespaces for EntryType names. For example, if you have 3 EntryTypes "one", "two" and "three" related to the concept "tx" in your Holochain application, you can name them "tx/one", "tx/two" and "tx/three". Then, when you want to query all of your tx-related entries from your local chain, you'd call

hdk::query( "tx/*".into() )

Later, when you add a fourth "tx/four" EntryType, the above code would automatically get all the tx-related EntryTypes.

You can also do things like get all EntryTypes except the System EntryTypes: "[!%]*".

NOTE: Changes the hdk::query API!

o Change the Holochain query API to accept a Vec<String> vs. String
o If multiple EntryType names (or one with "glob" wildcards) is used,
  then produce a GlobSetBuilder matcher to recognize the selected names.
o hdk::query( "post".into() or vec!["post","whatever"].into() work
Copy link
Member

@zippy zippy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. There are a couple TODOs that need to be converted to followup tickets and the ticket number added into the code so at least there's and internal and external reference to the followup.

@pjkundert
Copy link
Contributor Author

OK, TODOs ticketed. Should be good to do!

Copy link
Collaborator

@Connoropolous Connoropolous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we know this will keep evolving, but this is a nice improvement!

@zippy zippy merged commit a8c7dc0 into develop Dec 22, 2018
@zippy zippy removed the review label Dec 22, 2018
@zippy zippy deleted the feature-query-matching branch January 10, 2019 17:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants