Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@
"sessionId is required for query optimization": "sessionId is required for query optimization",
"Settings:": "Settings:",
"Severe multikey expansion": "Severe multikey expansion",
"Shard Key": "Shard Key",
"SHARD_MERGE · {0} shards": "SHARD_MERGE · {0} shards",
"SHARD_MERGE · {0} shards · {1} docs · {2}ms": "SHARD_MERGE · {0} shards · {1} docs · {2}ms",
"Shard: {0}": "Shard: {0}",
Expand Down
10 changes: 9 additions & 1 deletion src/documentdb/ClustersClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface DatabaseItemModel {
export interface CollectionItemModel {
name: string;
type?: string;
shardKey?: Record<string, number | string>;
}

/**
Expand Down Expand Up @@ -602,7 +603,14 @@ export class ClustersClient {
}

const rawCollections = await this._mongoClient.db(databaseName).listCollections().toArray();
const collections: CollectionItemModel[] = rawCollections;
const collections: CollectionItemModel[] = rawCollections.map((c) => ({
name: c.name,
type: c.type,
shardKey:
'options' in c
? (c.options as { shardKey?: Record<string, number | string> } | undefined)?.shardKey
: undefined,
}));

this._collectionsCache.set(databaseName, collections);

Expand Down
16 changes: 16 additions & 0 deletions src/tree/documentdb/CollectionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ export class CollectionItem implements TreeElement, TreeElementWithExperience, T
md.appendMarkdown(`**${l10n.t('Documents')}:** ${formatDocumentCount(this.documentCount)}\n\n`);
}

// Shard key
if (this.collectionInfo.shardKey) {
const shardKeyEntries = Object.entries(this.collectionInfo.shardKey);
if (shardKeyEntries.length > 0) {
const entries = shardKeyEntries
.map(([k, v]) => {
const escapedKey = escapeMarkdown(k);
const valueText = typeof v === 'string' ? `"${v}"` : String(v);
const escapedValue = escapeMarkdown(valueText);
return `${escapedKey}: ${escapedValue}`;
})
.join(', ');
md.appendMarkdown(`**${l10n.t('Shard Key')}:** \`{ ${entries} }\`\n\n`);
}
}

return md;
}
}