mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-13 05:15:30 +00:00
* ru threshold beta * use new ru threshold package * fix typo * fix merge issue * fix package-lock.json * fix test * fixed settings pane test * fixed merge issue * sync with main * fixed settings pane check * fix checks * fixed aria-label error * fixed aria-label error * fixed aria-label error * fixed aria-label error * remove learn more --------- Co-authored-by: Asier Isayas <aisayas@microsoft.com>
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import { QueryOperationOptions } from "@azure/cosmos";
|
|
import { QueryResults } from "../../Contracts/ViewModels";
|
|
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
import { getEntityName } from "../DocumentUtility";
|
|
import { handleError } from "../ErrorHandlingUtils";
|
|
import { MinimalQueryIterator, nextPage } from "../IteratorUtilities";
|
|
|
|
export const queryDocumentsPage = async (
|
|
resourceName: string,
|
|
documentsIterator: MinimalQueryIterator,
|
|
firstItemIndex: number,
|
|
queryOperationOptions?: QueryOperationOptions,
|
|
): Promise<QueryResults> => {
|
|
const entityName = getEntityName();
|
|
const clearMessage = logConsoleProgress(`Querying ${entityName} for container ${resourceName}`);
|
|
|
|
try {
|
|
const result: QueryResults = await nextPage(documentsIterator, firstItemIndex, queryOperationOptions);
|
|
const itemCount = (result.documents && result.documents.length) || 0;
|
|
logConsoleInfo(`Successfully fetched ${itemCount} ${entityName} for container ${resourceName}`);
|
|
return result;
|
|
} catch (error) {
|
|
handleError(error, "QueryDocumentsPage", `Failed to query ${entityName} for container ${resourceName}`);
|
|
throw error;
|
|
} finally {
|
|
clearMessage();
|
|
}
|
|
};
|