1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-07-22 15:18:02 +00:00
This commit is contained in:
2023-02-11 21:57:52 +01:00
parent ff3766ad85
commit 126b42d570
19 changed files with 168 additions and 84 deletions

View File

@ -1,7 +1,6 @@
package app
import (
"fmt"
"strings"
"github.com/wailsapp/wails/v2/pkg/runtime"
@ -18,7 +17,8 @@ func (a *App) InsertItems(hostKey, dbKey, collKey, jsonData string) interface{}
err := bson.UnmarshalExtJSON([]byte(jsonData), true, &data)
if err != nil {
fmt.Println(err.Error())
runtime.LogError(a.ctx, "Could not parse insert JSON:")
runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
Title: "Couldn't parse JSON",
@ -29,14 +29,14 @@ func (a *App) InsertItems(hostKey, dbKey, collKey, jsonData string) interface{}
client, ctx, close, err := a.connectToHost(hostKey)
if err != nil {
fmt.Println(err.Error())
return nil
}
defer close()
res, err := client.Database(dbKey).Collection(collKey).InsertMany(ctx, data)
if err != nil {
fmt.Println(err.Error())
runtime.LogWarning(a.ctx, "Encountered an error while performing insert:")
runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
Title: "Encountered an error while performing query",