Skip to content

Conversation

@shabaraba
Copy link
Member

@shabaraba shabaraba commented Dec 18, 2025

Why

refs: kintone/js-sdk-ja#51

The getAllRecordsWithCursor method internally uses createCursor API, which has a default size of 100 records per request. However, the maximum allowed value is 500. By using the maximum size, we can reduce the number of API calls needed to fetch all records, improving performance.

For example, fetching 1000 records:

  • With default size (100): 10 API calls
  • With size 500: 2 API calls

What

  • Set size: 500 when calling createCursor in getAllRecordsWithCursor method
  • Updated the corresponding test to verify the size parameter is passed correctly

How to test

  1. Run the unit tests:
cd packages/rest-api-client
pnpm test -- src/client/__tests__/record/AllRecords.test.ts
  1. Manual verification with a kintone app containing 1000+ records:
const records = await client.record.getAllRecordsWithCursor({ app: appId });
// Cursor should be created with size=500, reducing API calls

Checklist

  • Read CONTRIBUTING.md
  • Updated documentation if it is required.
  • Added tests if it is required.
  • Passed pnpm lint and pnpm test on the root directory.

@github-actions github-actions bot added the pkg: rest-api-client @kintone/rest-api-client label Dec 18, 2025
@shabaraba shabaraba marked this pull request as ready for review December 18, 2025 02:49
@shabaraba shabaraba requested a review from a team as a code owner December 18, 2025 02:49
@shabaraba shabaraba requested review from chihiro-adachi, Copilot and tasshi-me and removed request for a team December 18, 2025 02:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the getAllRecordsWithCursor method by setting the cursor size to the maximum allowed value of 500 records per request (up from the default of 100). This change significantly reduces the number of API calls needed to fetch large record sets, improving performance by up to 5x for operations that retrieve many records.

Key changes:

  • Modified getAllRecordsWithCursor to explicitly set size: 500 when creating cursors
  • Updated the corresponding test to verify the size parameter is correctly passed

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/rest-api-client/src/client/RecordClient.ts Added size: 500 parameter when calling createCursor within getAllRecordsWithCursor method
packages/rest-api-client/src/client/__tests__/record/AllRecords.test.ts Updated test to verify cursor is created with size 500 parameter

I've completed my review of this pull request. The implementation is correct, well-tested, and follows the existing codebase patterns. The change is a straightforward performance optimization that:

  1. Correctly uses the maximum allowed cursor size: The Kintone API documentation confirms that 500 is the maximum allowed size for cursors (as documented in packages/rest-api-client/docs/record.md line 488).

  2. Is backward compatible: The change is purely internal - it doesn't affect the public API surface or behavior from the user's perspective.

  3. Has appropriate test coverage: The test was correctly updated to verify the new behavior.

  4. Benefits multiple methods: Since getAllRecords with withCursor=true internally calls getAllRecordsWithCursor, it also benefits from this optimization.

The code changes are clean and minimal. No issues were found during the review.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const { id } = await this.createCursor(params);
const paramsWithSize = {
...params,
size: 500,
Copy link
Contributor

Choose a reason for hiding this comment

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

const DELETE_RECORDS_LIMIT = 100;

を使う方が良さそう

Suggested change
size: 500,
size: GET_RECORDS_LIMIT,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: rest-api-client @kintone/rest-api-client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants