The Query DSL(Domian Specific Language) allows to sort and filter recursively to any logical depth. This DSL can be used in conjunction with operators to sort, filter, and compute data in real-time.
The Query DSL can be applied to all
list
andget
API commands with awhere
parameter with the 5.1 release.
The following operators are supported for this API command-set:
[object
] - This selector key will evaluate the comparison on the raw binary object. - Depreciated
[results
] - This selector key will evaluate the comparison on the results json.
The following object classes are supported:
date(`YYYY-MM-DD`); -> This will generate a unix timestamp and replace this variable with it for checking date ranges
resolve(`viz:default`); -> This will resolve name and generate address to query by
name(`address`); -> This will get the name record resolved by the address reverse lookup.
username(`US:Interactions`); -> This will resolve to the profile genesis to query.
The variables are enclosed with
backticks
" ` " and not with single quote.
Examples:
register/list/finance:accounts,finance:trust/total/sum limit=none where='results.modified>date(`2023-1-1`); AND results.total>10 AND results.ticker=NXS'
register/list/invoices:invoice limit=20 where='results.json.recipient=username(`US:Interactions`);'
If you are searching by a string parameter, you can include '*' as an any character wildcard match, so that you can search values based on a partial match.
register/list/accounts WHERE 'object.name=d*'
The above will return all accounts that start with a letter 'd'.
The following demonstrates how to check with wildcards.
register/list/accounts WHERE 'object.name=*d'
This above will return all accounts that have a name ending with letter 'd'.
To filter, you can use where='statements' or follow the command with WHERE string:
The below clause will filter all name object registers, that are Global names that start with letter 'P', or any objects that start with letter 'S'.
register/list/names WHERE '(object.namespace=*GLOBAL* AND object.name=P*) OR object.name=S*'
Using the object class i.e. 'object.namespace' will invoke the filter on the binary object.
The below clause will filter all name object registers, that are Global names that start with letter 'P', or any objects that start with letter 'S'.
register/list/names where='(object.namespace=*GLOBAL* AND object.name=P*) OR object.name=S*'
The below will return all NXS accounts that have a balance greater than 10 NXS.
register/list/accounts WHERE 'object.token=0 AND object.balance>10'
The following demonstrates how to query using multiple recursive levels.
register/list/accounts WHERE '(object.token=0 AND object.balance>10) OR (object.token=8Ed7Gzybwy3Zf6X7hzD4imJwmA2v1EYjH2MNGoVRdEVCMTCdhdK AND object.balance>1)'
This will give all NXS accounts with balance greater than 10, or all accounts for token '8Ed7Gzybwy3Zf6X7hzD4imJwmA2v1EYjH2MNGoVRdEVCMTCdhdK' with balance greater than 1.
There is no current limit to the number of levels of recursion, such as:
register/list/names WHERE '((object.name=d* AND object.namespace=~GLOBAL~) OR (object.name=e* AND object.namespace=send.to)) OR object.namespace=*s'
The above command will return all objects starting with letter 'd' that are global names, or all objects starting with letter 'e' in the 'send.to' namespace, or finally all objects that are in a namespace that ends with the letter 's'.