1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-07-19 22:18:03 +00:00

Drop active item in find.svelte

This commit is contained in:
2023-01-19 09:18:21 +01:00
parent a153858730
commit 3d97f3b92f
4 changed files with 42 additions and 5 deletions

View File

@ -67,3 +67,28 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
return res.DeletedCount
}
func (a *App) RemoveItemById(hostKey, dbKey, collKey, itemId string) bool {
client, ctx, close, err := a.connectToHost(hostKey)
if err != nil {
fmt.Println(err.Error())
return false
}
defer close()
filter := bson.M{"_id": itemId}
err = client.Database(dbKey).Collection(collKey).FindOneAndDelete(ctx, filter).Err()
if err != nil && err != mongo.ErrNoDocuments {
fmt.Println(err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
Title: "Encountered an error while performing query",
Message: err.Error(),
})
return false
}
return err == nil
}