diff --git a/frontend/src/organisms/connection/collection/indexes.svelte b/frontend/src/organisms/connection/collection/indexes.svelte
index 744f7e7..2f43f04 100644
--- a/frontend/src/organisms/connection/collection/indexes.svelte
+++ b/frontend/src/organisms/connection/collection/indexes.svelte
@@ -1,7 +1,7 @@
@@ -25,7 +35,9 @@
-
+
diff --git a/frontend/wailsjs/go/app/App.d.ts b/frontend/wailsjs/go/app/App.d.ts
index 64e2680..71a6f40 100755
--- a/frontend/wailsjs/go/app/App.d.ts
+++ b/frontend/wailsjs/go/app/App.d.ts
@@ -8,6 +8,8 @@ export function DropCollection(arg1:string,arg2:string,arg3:string):Promise
;
+export function DropIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise;
+
export function FindItems(arg1:string,arg2:string,arg3:string,arg4:string):Promise;
export function GetIndexes(arg1:string,arg2:string,arg3:string):Promise>;
diff --git a/frontend/wailsjs/go/app/App.js b/frontend/wailsjs/go/app/App.js
index 79f6903..0951f40 100755
--- a/frontend/wailsjs/go/app/App.js
+++ b/frontend/wailsjs/go/app/App.js
@@ -10,6 +10,10 @@ export function DropDatabase(arg1, arg2) {
return window['go']['app']['App']['DropDatabase'](arg1, arg2);
}
+export function DropIndex(arg1, arg2, arg3, arg4) {
+ return window['go']['app']['App']['DropIndex'](arg1, arg2, arg3, arg4);
+}
+
export function FindItems(arg1, arg2, arg3, arg4) {
return window['go']['app']['App']['FindItems'](arg1, arg2, arg3, arg4);
}
diff --git a/internal/app/collection_indexes.go b/internal/app/collection_indexes.go
index 713a321..46cee48 100644
--- a/internal/app/collection_indexes.go
+++ b/internal/app/collection_indexes.go
@@ -5,6 +5,7 @@ import (
"github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson"
+ "go.mongodb.org/mongo-driver/mongo/options"
)
func (a *App) GetIndexes(hostKey, dbKey, collKey string) []bson.M {
@@ -40,3 +41,25 @@ func (a *App) GetIndexes(hostKey, dbKey, collKey string) []bson.M {
return results
}
+
+func (a *App) DropIndex(hostKey, dbKey, collKey, indexName string) bool {
+ client, ctx, close, err := a.connectToHost(hostKey)
+ if err != nil {
+ fmt.Println(err.Error())
+ return false
+ }
+ defer close()
+
+ _, err = client.Database(dbKey).Collection(collKey).Indexes().DropOne(ctx, indexName, &options.DropIndexesOptions{})
+ if err != nil {
+ fmt.Println(err.Error())
+ runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
+ Type: runtime.ErrorDialog,
+ Title: "Encountered an error while creating index cursor",
+ Message: err.Error(),
+ })
+ return false
+ }
+
+ return true
+}