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

Show BSON types correctly

This commit is contained in:
2023-01-24 20:55:53 +01:00
parent b58a2ca84f
commit ae811bc0d5
7 changed files with 183 additions and 13 deletions

View File

@ -11,8 +11,8 @@ import (
)
type findResult struct {
Total int64 `json:"total"`
Results interface{} `json:"results"`
Total int64 `json:"total"`
Results []string `json:"results"`
}
func (a *App) FindItems(hostKey, dbKey, collKey string, formJson string) findResult {
@ -123,7 +123,23 @@ func (a *App) FindItems(hostKey, dbKey, collKey string, formJson string) findRes
return out
}
out.Results = results
out.Results = make([]string, 0)
out.Total = total
for _, r := range results {
marshalled, err := bson.MarshalExtJSON(r, true, true)
if err != nil {
fmt.Println(err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
Title: "Failed to marshal BSON",
Message: err.Error(),
})
return out
}
out.Results = append(out.Results, string(marshalled))
}
fmt.Println(out.Results)
return out
}