mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-04-01 07:28:24 +01:00
22 lines
817 B
TypeScript
22 lines
817 B
TypeScript
import * as DataModels from "../../Contracts/DataModels";
|
|
import { client } from "../CosmosClient";
|
|
import { handleError } from "../ErrorHandlingUtils";
|
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
|
|
export async function readCollection(databaseId: string, collectionId: string): Promise<DataModels.Collection> {
|
|
let collection: DataModels.Collection;
|
|
const clearMessage = logConsoleProgress(`Querying container ${collectionId}`);
|
|
try {
|
|
const response = await client()
|
|
.database(databaseId)
|
|
.container(collectionId)
|
|
.read();
|
|
collection = response.resource as DataModels.Collection;
|
|
} catch (error) {
|
|
handleError(error, "ReadCollection", `Error while querying container ${collectionId}`);
|
|
throw error;
|
|
}
|
|
clearMessage();
|
|
return collection;
|
|
}
|