mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-04 00:31:41 +00:00
Move readCollection, readCollections, and readDatabases to ARM (#134)
This commit is contained in:
@@ -806,63 +806,6 @@ export function refreshCachedOffers(): Q.Promise<void> {
|
||||
return DataAccessUtilityBase.refreshCachedOffers();
|
||||
}
|
||||
|
||||
export function readCollections(database: ViewModels.Database, options: any = {}): Q.Promise<DataModels.Collection[]> {
|
||||
var deferred = Q.defer<DataModels.Collection[]>();
|
||||
const id = NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.InProgress,
|
||||
`Querying containers for database ${database.id()}`
|
||||
);
|
||||
DataAccessUtilityBase.readCollections(database, options)
|
||||
.then(
|
||||
(collections: DataModels.Collection[]) => {
|
||||
deferred.resolve(collections);
|
||||
},
|
||||
(error: any) => {
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Error,
|
||||
`Error while querying containers for database ${database.id()}:\n ${JSON.stringify(error)}`
|
||||
);
|
||||
Logger.logError(JSON.stringify(error), "ReadCollections", error.code);
|
||||
sendNotificationForError(error);
|
||||
deferred.reject(error);
|
||||
}
|
||||
)
|
||||
.finally(() => {
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(id);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
export function readCollection(databaseId: string, collectionId: string): Q.Promise<DataModels.Collection> {
|
||||
const deferred = Q.defer<DataModels.Collection>();
|
||||
const id = NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.InProgress,
|
||||
`Querying container ${collectionId}`
|
||||
);
|
||||
|
||||
DataAccessUtilityBase.readCollection(databaseId, collectionId)
|
||||
.then(
|
||||
(collection: DataModels.Collection) => {
|
||||
deferred.resolve(collection);
|
||||
},
|
||||
(error: any) => {
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Error,
|
||||
`Error while querying containers for database ${databaseId}:\n ${JSON.stringify(error)}`
|
||||
);
|
||||
Logger.logError(JSON.stringify(error), "ReadCollections", error.code);
|
||||
sendNotificationForError(error);
|
||||
deferred.reject(error);
|
||||
}
|
||||
)
|
||||
.finally(() => {
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(id);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
export function readCollectionQuotaInfo(
|
||||
collection: ViewModels.Collection,
|
||||
options?: any
|
||||
@@ -950,31 +893,6 @@ export function readOffer(
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
export function readDatabases(options: any): Q.Promise<DataModels.Database[]> {
|
||||
var deferred = Q.defer<any>();
|
||||
const id = NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.InProgress, "Querying databases");
|
||||
DataAccessUtilityBase.readDatabases(options)
|
||||
.then(
|
||||
(databases: DataModels.Database[]) => {
|
||||
deferred.resolve(databases);
|
||||
},
|
||||
(error: any) => {
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Error,
|
||||
`Error while querying databases:\n ${JSON.stringify(error)}`
|
||||
);
|
||||
Logger.logError(JSON.stringify(error), "ReadDatabases", error.code);
|
||||
sendNotificationForError(error);
|
||||
deferred.reject(error);
|
||||
}
|
||||
)
|
||||
.finally(() => {
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(id);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
export function getOrCreateDatabaseAndCollection(
|
||||
request: DataModels.CreateDatabaseAndCollectionRequest,
|
||||
options: any = {}
|
||||
|
||||
Reference in New Issue
Block a user