Add pagination to list records CLI #82

Merged
nabarun merged 3 commits from deep-stack/laconic-registry-cli:iv-update-queryRecords-pagination into main 2024-09-05 13:51:43 +00:00
Showing only changes of commit 25fd5a4e4a - Show all commits

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) {