Fixed setup save queries within serverless accounts (#1626)

* Fixed setup save queries within serverless accounts

* Fixed format

* ran prettier
This commit is contained in:
JustinKol 2023-10-04 14:23:22 -04:00 committed by GitHub
parent 68b45e77a8
commit 07d242f972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 20 deletions

View File

@ -13,6 +13,7 @@ import { createDocument } from "./dataAccess/createDocument";
import { deleteDocument } from "./dataAccess/deleteDocument";
import { queryDocuments } from "./dataAccess/queryDocuments";
import { handleError } from "./ErrorHandlingUtils";
import { isServerlessAccount } from "Utils/CapabilityUtils";
export class QueriesClient {
private static readonly PartitionKey: DataModels.PartitionKey = {
@ -32,6 +33,16 @@ export class QueriesClient {
}
const clearMessage = NotificationConsoleUtils.logConsoleProgress("Setting up account for saving queries");
if (isServerlessAccount()) {
return createCollection({
collectionId: SavedQueries.CollectionName,
createNewDatabase: true,
databaseId: SavedQueries.DatabaseName,
partitionKey: QueriesClient.PartitionKey,
databaseLevelThroughput: false,
});
} else {
return createCollection({
collectionId: SavedQueries.CollectionName,
createNewDatabase: true,
@ -52,6 +63,7 @@ export class QueriesClient {
)
.finally(() => clearMessage());
}
}
public async saveQuery(query: DataModels.Query): Promise<void> {
const queriesCollection = this.findQueriesCollection();

View File

@ -318,7 +318,7 @@ export interface CreateCollectionParams {
collectionId: string;
databaseId: string;
databaseLevelThroughput: boolean;
offerThroughput: number;
offerThroughput?: number;
analyticalStorageTtl?: number;
autoPilotMaxThroughput?: number;
indexingPolicy?: IndexingPolicy;

View File

@ -113,6 +113,7 @@ export const SaveQueryPane: FunctionComponent<SaveQueryPaneProps> = ({
},
startKey,
);
closeSidePanel();
} catch (error) {
const errorMessage = getErrorMessage(error);
traceFailure(