From c7b5486ef0aaa453398267b7987dffd799a9ad7f Mon Sep 17 00:00:00 2001 From: Simon Esposito Date: Mon, 21 Oct 2024 18:01:15 +0100 Subject: [PATCH] NK-588 Add storage index listing pagination support (#161) --- CHANGELOG.md | 3 +++ index.d.ts | 7 ++++++- runtime/runtime.go | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5033c62..003a999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org). ## [Unreleased] +### Changed +- Added pagination support to storage index listing. + ### Added - New runtime function to list user notifications. diff --git a/index.d.ts b/index.d.ts index 76f6672..030e78b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3126,6 +3126,11 @@ declare namespace nkruntime { status?: string } + export interface StorageIndexResult { + objects: StorageObject[] + cursor: string | null + } + export interface EnvelopeStatusUpdate { statusUpdate: StatusUpdateMessage } @@ -4990,7 +4995,7 @@ declare namespace nkruntime { * @returns A list of storage objects matching the query criteria. * @throws {TypeError, GoError} */ - storageIndexList(indexName: string, query: string, limit: number, order?: string[], callerId?: string | void): StorageObject[]; + storageIndexList(indexName: string, query: string, limit: number, order?: string[], callerId?: string | void, cursor?: string): StorageIndexResult; /** * Get Satori object. diff --git a/runtime/runtime.go b/runtime/runtime.go index 63f7a73..c9664bb 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -1118,7 +1118,7 @@ type NakamaModule interface { StorageRead(ctx context.Context, reads []*StorageRead) ([]*api.StorageObject, error) StorageWrite(ctx context.Context, writes []*StorageWrite) ([]*api.StorageObjectAck, error) StorageDelete(ctx context.Context, deletes []*StorageDelete) error - StorageIndexList(ctx context.Context, callerID, indexName, query string, limit int, order []string) (*api.StorageObjects, error) + StorageIndexList(ctx context.Context, callerID, indexName, query string, limit int, order []string, cursor string) (*api.StorageObjects, string, error) MultiUpdate(ctx context.Context, accountUpdates []*AccountUpdate, storageWrites []*StorageWrite, storageDeletes []*StorageDelete, walletUpdates []*WalletUpdate, updateLedger bool) ([]*api.StorageObjectAck, []*WalletUpdateResult, error)