mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 00:41:31 +00:00
Fix for Mongo shard key loaded via ARM (#657)
This commit is contained in:
@@ -513,9 +513,7 @@ export default class Collection implements ViewModels.Collection {
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "Documents",
|
||||
tabPath: "",
|
||||
|
||||
collection: this,
|
||||
|
||||
node: this,
|
||||
hashLocation: `${Constants.HashRoutePrefixes.collectionsWithIds(this.databaseId, this.id())}/mongoDocuments`,
|
||||
isActive: ko.observable(false),
|
||||
|
||||
@@ -172,6 +172,27 @@ export default class Database implements ViewModels.Database {
|
||||
public async loadCollections(): Promise<void> {
|
||||
const collectionVMs: Collection[] = [];
|
||||
const collections: DataModels.Collection[] = await readCollections(this.id());
|
||||
// TODO Remove
|
||||
// This is a hack to make Mongo collections read via ARM have a SQL-ish partitionKey property
|
||||
if (userContext.apiType === "Mongo") {
|
||||
collections.map((collection) => {
|
||||
if (collection.shardKey) {
|
||||
const shardKey = Object.keys(collection.shardKey)[0];
|
||||
collection.partitionKey = {
|
||||
version: undefined,
|
||||
kind: "Hash",
|
||||
paths: [`/"$v"/"${shardKey.split(".").join(`"/"$v"/"`)}"/"$v"`],
|
||||
};
|
||||
} else {
|
||||
collection.partitionKey = {
|
||||
paths: ["/'$v'/'_partitionKey'/'$v'"],
|
||||
kind: "Hash",
|
||||
version: 2,
|
||||
systemKey: true,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
const deltaCollections = this.getDeltaCollections(collections);
|
||||
|
||||
collections.forEach((collection: DataModels.Collection) => {
|
||||
|
||||
Reference in New Issue
Block a user