UNPKG

@ibm-cloud/cloudant

Version:
50 lines 2.01 kB
"use strict"; /** * © Copyright IBM Corporation 2025. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ViewBasePageIterator = void 0; const keyPageIterator_1 = require("./keyPageIterator"); class ViewBasePageIterator extends keyPageIterator_1.KeyPageIterator { getItems(result) { return result.rows; } setNextKeyId(startKeyDocId) { this.nextPageParams.startKeyDocId = startKeyDocId; } checkBoundary(penultimateItem, lastItem) { const penultimateId = penultimateItem.id; const lastId = lastItem.id; if (penultimateId === lastId) { // ID's are the same, check the keys const penultimateKey = penultimateItem.key; const lastKey = lastItem.key; if (penultimateKey === lastKey) { // Identical keys, set an error message return `Cannot paginate on a boundary containing identical keys '${lastKey}' and document IDs '${lastId}'`; } } return null; } getValidateParamsAbsentErrorMessage(paramName) { let errorMsg = super.getValidateParamsAbsentErrorMessage(paramName); if (paramName === 'key') { errorMsg = `${errorMsg} Use 'start_key' and 'end_key' instead.`; } return errorMsg; } } exports.ViewBasePageIterator = ViewBasePageIterator; //# sourceMappingURL=viewBasePageIterator.js.map