Fixed setup save queries within serverless accounts (#1626)
* Fixed setup save queries within serverless accounts * Fixed format * ran prettier
This commit is contained in:
parent
68b45e77a8
commit
07d242f972
|
@ -13,6 +13,7 @@ import { createDocument } from "./dataAccess/createDocument";
|
||||||
import { deleteDocument } from "./dataAccess/deleteDocument";
|
import { deleteDocument } from "./dataAccess/deleteDocument";
|
||||||
import { queryDocuments } from "./dataAccess/queryDocuments";
|
import { queryDocuments } from "./dataAccess/queryDocuments";
|
||||||
import { handleError } from "./ErrorHandlingUtils";
|
import { handleError } from "./ErrorHandlingUtils";
|
||||||
|
import { isServerlessAccount } from "Utils/CapabilityUtils";
|
||||||
|
|
||||||
export class QueriesClient {
|
export class QueriesClient {
|
||||||
private static readonly PartitionKey: DataModels.PartitionKey = {
|
private static readonly PartitionKey: DataModels.PartitionKey = {
|
||||||
|
@ -32,25 +33,36 @@ export class QueriesClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearMessage = NotificationConsoleUtils.logConsoleProgress("Setting up account for saving queries");
|
const clearMessage = NotificationConsoleUtils.logConsoleProgress("Setting up account for saving queries");
|
||||||
return createCollection({
|
|
||||||
collectionId: SavedQueries.CollectionName,
|
if (isServerlessAccount()) {
|
||||||
createNewDatabase: true,
|
return createCollection({
|
||||||
databaseId: SavedQueries.DatabaseName,
|
collectionId: SavedQueries.CollectionName,
|
||||||
partitionKey: QueriesClient.PartitionKey,
|
createNewDatabase: true,
|
||||||
offerThroughput: SavedQueries.OfferThroughput,
|
databaseId: SavedQueries.DatabaseName,
|
||||||
databaseLevelThroughput: false,
|
partitionKey: QueriesClient.PartitionKey,
|
||||||
})
|
databaseLevelThroughput: false,
|
||||||
.then(
|
});
|
||||||
(collection: DataModels.Collection) => {
|
} else {
|
||||||
NotificationConsoleUtils.logConsoleInfo("Successfully set up account for saving queries");
|
return createCollection({
|
||||||
return Promise.resolve(collection);
|
collectionId: SavedQueries.CollectionName,
|
||||||
},
|
createNewDatabase: true,
|
||||||
(error: any) => {
|
databaseId: SavedQueries.DatabaseName,
|
||||||
handleError(error, "setupQueriesCollection", "Failed to set up account for saving queries");
|
partitionKey: QueriesClient.PartitionKey,
|
||||||
return Promise.reject(error);
|
offerThroughput: SavedQueries.OfferThroughput,
|
||||||
},
|
databaseLevelThroughput: false,
|
||||||
)
|
})
|
||||||
.finally(() => clearMessage());
|
.then(
|
||||||
|
(collection: DataModels.Collection) => {
|
||||||
|
NotificationConsoleUtils.logConsoleInfo("Successfully set up account for saving queries");
|
||||||
|
return Promise.resolve(collection);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(error, "setupQueriesCollection", "Failed to set up account for saving queries");
|
||||||
|
return Promise.reject(error);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.finally(() => clearMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async saveQuery(query: DataModels.Query): Promise<void> {
|
public async saveQuery(query: DataModels.Query): Promise<void> {
|
||||||
|
|
|
@ -318,7 +318,7 @@ export interface CreateCollectionParams {
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
databaseId: string;
|
databaseId: string;
|
||||||
databaseLevelThroughput: boolean;
|
databaseLevelThroughput: boolean;
|
||||||
offerThroughput: number;
|
offerThroughput?: number;
|
||||||
analyticalStorageTtl?: number;
|
analyticalStorageTtl?: number;
|
||||||
autoPilotMaxThroughput?: number;
|
autoPilotMaxThroughput?: number;
|
||||||
indexingPolicy?: IndexingPolicy;
|
indexingPolicy?: IndexingPolicy;
|
||||||
|
|
|
@ -113,6 +113,7 @@ export const SaveQueryPane: FunctionComponent<SaveQueryPaneProps> = ({
|
||||||
},
|
},
|
||||||
startKey,
|
startKey,
|
||||||
);
|
);
|
||||||
|
closeSidePanel();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = getErrorMessage(error);
|
const errorMessage = getErrorMessage(error);
|
||||||
traceFailure(
|
traceFailure(
|
||||||
|
|
Loading…
Reference in New Issue