Add pagination to list records CLI
Some checks failed
Lint / lint (18.x) (pull_request) Successful in 1m11s
Tests / cli_tests (18.x) (pull_request) Failing after 1m13s

This commit is contained in:
IshaVenikar 2024-08-30 09:47:36 +05:30 committed by Prathamesh Musale
parent 6055da62c7
commit 25fd5a4e4a

View File

@ -24,13 +24,23 @@ export const builder = {
all: { all: {
type: 'boolean', type: 'boolean',
default: false default: false
},
refs: {
type: 'boolean',
default: false
},
limit: {
type: 'number'
},
offset: {
type: 'number'
} }
}; };
export const handler = async (argv: Arguments) => { export const handler = async (argv: Arguments) => {
const { services: { registry: registryConfig } } = getConfig(argv.config as string); const { services: { registry: registryConfig } } = getConfig(argv.config as string);
const { rpcEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); const { rpcEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
const { type, name, bondId, owner, all } = argv; const { type, name, bondId, owner, all, refs, limit, offset } = argv;
const filters: any = {}; const filters: any = {};
const filterArgs = argv._.slice(3); const filterArgs = argv._.slice(3);
@ -44,7 +54,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId); const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
let result = await registry.queryRecords({ ...filters, type, name }, all as boolean); let result = await registry.queryRecords({ ...filters, type, name }, all as boolean, refs as boolean, limit as number, offset as number);
// Apply ex post filters. // Apply ex post filters.
if (bondId) { if (bondId) {