File tree Expand file tree Collapse file tree 2 files changed +65
-8
lines changed Expand file tree Collapse file tree 2 files changed +65
-8
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,17 @@ import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js";
4
4
import { ToolArgs , OperationType } from "../../tool.js" ;
5
5
import { checkIndexUsage } from "../../../helpers/indexCheck.js" ;
6
6
7
+ export function deleteManyResponse ( collection : string , delectedCount : number ) : CallToolResult {
8
+ return {
9
+ content : [
10
+ {
11
+ text : `Deleted \`${ delectedCount } \` document(s) from collection "${ collection } "` ,
12
+ type : "text" ,
13
+ } ,
14
+ ] ,
15
+ } ;
16
+ }
17
+
7
18
export class DeleteManyTool extends MongoDBToolBase {
8
19
protected name = "delete-many" ;
9
20
protected description = "Removes all documents that match the filter from a MongoDB collection" ;
@@ -45,13 +56,6 @@ export class DeleteManyTool extends MongoDBToolBase {
45
56
46
57
const result = await provider . deleteMany ( database , collection , filter ) ;
47
58
48
- return {
49
- content : [
50
- {
51
- text : `Deleted \`${ result . deletedCount } \` document(s) from collection "${ collection } "` ,
52
- type : "text" ,
53
- } ,
54
- ] ,
55
- } ;
59
+ return deleteManyResponse ( collection , result . deletedCount ) ;
56
60
}
57
61
}
Original file line number Diff line number Diff line change
1
+ import { describeAccuracyTests } from "./sdk/describe-accuracy-tests.js" ;
2
+ import { getAvailableModels } from "./sdk/models.js" ;
3
+ import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js" ;
4
+ import { deleteManyResponse } from "../../src/tools/mongodb/delete/deleteMany.js" ;
5
+
6
+ function callsDeleteManyWithEmptyFilters ( prompt : string ) : AccuracyTestConfig {
7
+ return {
8
+ injectConnectedAssumption : true ,
9
+ prompt : prompt ,
10
+ mockedTools : {
11
+ "delete-many" : function listDatabases ( ) {
12
+ return deleteManyResponse ( "coll1" , 10 ) ;
13
+ } ,
14
+ } ,
15
+ expectedToolCalls : [
16
+ {
17
+ toolName : "delete-many" ,
18
+ parameters : {
19
+ database : "db1" ,
20
+ collection : "coll1" ,
21
+ } ,
22
+ } ,
23
+ ] ,
24
+ } ;
25
+ }
26
+
27
+ function callsDeleteManyWithFilters ( prompt : string ) : AccuracyTestConfig {
28
+ return {
29
+ injectConnectedAssumption : true ,
30
+ prompt : prompt ,
31
+ mockedTools : {
32
+ "delete-many" : function listDatabases ( ) {
33
+ return deleteManyResponse ( "coll1" , 10 ) ;
34
+ } ,
35
+ } ,
36
+ expectedToolCalls : [
37
+ {
38
+ toolName : "delete-many" ,
39
+ parameters : {
40
+ database : "db1" ,
41
+ collection : "coll1" ,
42
+ filters : { provider : "BongoDB" } ,
43
+ } ,
44
+ } ,
45
+ ] ,
46
+ } ;
47
+ }
48
+
49
+ describeAccuracyTests ( "delete-many" , getAvailableModels ( ) , [
50
+ callsDeleteManyWithEmptyFilters ( "Delete all the documents from 'db1.coll1' namespace" ) ,
51
+ callsDeleteManyWithEmptyFilters ( "Purge the collection 'coll1' in database 'db1'" ) ,
52
+ callsDeleteManyWithFilters ( "Remove all the documents from namespace 'db1.coll1' where provider is 'BongoDB'" ) ,
53
+ ] ) ;
You can’t perform that action at this time.
0 commit comments