Skip to content

Commit 39aa3ac

Browse files
committed
fix(schema): Use sample instead of find for schema sampling.
1 parent c10955a commit 39aa3ac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tools/mongodb/metadata/collectionSchema.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export class CollectionSchemaTool extends MongoDBToolBase {
1313

1414
protected async execute({ database, collection }: ToolArgs<typeof DbOperationArgs>): Promise<CallToolResult> {
1515
const provider = await this.ensureConnected();
16-
const documents = await provider.find(database, collection, {}, { limit: 5 }).toArray();
16+
const documents = await provider.aggregate(database, collection, [
17+
{ $sample: { size: 50 } },
18+
]).toArray();
1719
const schema = await getSimplifiedSchema(documents);
1820

1921
const fieldsCount = Object.entries(schema).length;

0 commit comments

Comments
 (0)