form {
display: grid;
- grid-template: auto / 1fr;
+ grid-template: auto auto 1fr auto / 1fr;
+ gap: 0.5rem;
}
.location {
display: grid;
@@ -163,17 +174,9 @@
}
.location .grid {
border: 1px solid #ccc;
- padding: 0.3rem;
overflow-y: auto;
}
- .meta {
- display: grid;
- grid-template: 1fr / 1fr 1fr;
- gap: 0.5rem;
- margin-bottom: 0.5rem;
- }
-
select.filetype {
flex: 0 1;
}
diff --git a/frontend/src/organisms/connection/hosttree.svelte b/frontend/src/organisms/connection/hosttree.svelte
index 9ab3987..d5feffa 100644
--- a/frontend/src/organisms/connection/hosttree.svelte
+++ b/frontend/src/organisms/connection/hosttree.svelte
@@ -102,8 +102,8 @@
name: collKey,
icon: 'list',
menu: [
- { label: 'Export collection (JSON/CSV, mongoexport)…', fn: () => dispatch('exportCollection', collKey) },
- { label: 'Dump collection (BSON, mongodump)…', fn: () => dispatch('dumpCollection', collKey) },
+ { label: 'Export collection (JSON, CSV)…', fn: () => dispatch('exportCollection', collKey) },
+ { label: 'Dump collection (BSON via mongodump)…', fn: () => dispatch('dumpCollection', collKey) },
{ separator: true },
{ label: 'Rename collection…', fn: () => dispatch('renameCollection', collKey) },
{ label: 'Truncate collection…', fn: () => truncateCollection(dbKey, collKey) },
diff --git a/internal/app/database_export.go b/internal/app/database_export.go
index f229949..8bc4da0 100644
--- a/internal/app/database_export.go
+++ b/internal/app/database_export.go
@@ -10,24 +10,19 @@ import (
"github.com/wailsapp/wails/v2/pkg/runtime"
)
-type ExportType string
type FileType string
type ExportInfo struct {
- Type ExportType `json:"type"`
- FileType FileType `json:"fileType"`
- OutDir string `json:"outdir"`
- Filename string `json:"filename"`
- HostKey string `json:"hostKey"`
- DbKey string `json:"dbKey"`
- CollKeys []string `json:"collKeys"`
+ FileType FileType `json:"fileType"`
+ OutDir string `json:"outdir"`
+ Filename string `json:"filename"`
+ HostKey string `json:"hostKey"`
+ DbKey string `json:"dbKey"`
+ CollKeys []string `json:"collKeys"`
}
const (
- ExportTypeExport ExportType = "export"
- ExportTypeDump ExportType = "dump"
-
FileTypeJson FileType = "json"
- FileTypeBson FileType = "bson"
+ FileTypeDump FileType = "dump"
FileTypeCsv FileType = "csv"
)
@@ -56,19 +51,22 @@ func (a *App) PerformExport(jsonData string) bool {
}
host := hosts[info.HostKey]
- switch info.Type {
- case ExportTypeExport:
- if !a.Env.HasMongoExport {
+ switch info.FileType {
+ case FileTypeCsv:
+
+ case FileTypeJson:
+
+ case FileTypeDump:
+ if !a.Env.HasMongoDump {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
- Title: "You need to install mongoexport to perform an export.",
+ Title: "You need to install mongodump to perform a dump.",
})
return false
}
args := make([]string, 0)
args = append(args, fmt.Sprintf(`--uri="%v"`, host.URI))
- args = append(args, fmt.Sprintf(`--type="%v"`, info.FileType))
if info.DbKey != "" {
args = append(args, fmt.Sprintf(`--db="%v"`, info.DbKey))
@@ -79,34 +77,25 @@ func (a *App) PerformExport(jsonData string) bool {
}
args = append(args, fmt.Sprintf(`--out="%v.%v"`, path.Join(info.OutDir, info.Filename), info.FileType))
- cmd := exec.Command("mongoexport", args...)
+ cmd := exec.Command("mongodump", args...)
var stdout strings.Builder
var stderr strings.Builder
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err = cmd.Run()
- runtime.LogInfo(a.ctx, "Performing export with args: "+strings.Join(args, " "))
-
- fmt.Println(args)
- fmt.Println(stdout.String())
- fmt.Println(stderr.String())
- fmt.Println(err)
-
- case ExportTypeDump:
- if !a.Env.HasMongoDump {
- runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
- Type: runtime.ErrorDialog,
- Title: "You need to install mongodump to perform a dump.",
- })
- return false
+ runtime.LogInfo(a.ctx, "Performing dump, executing command: mongodump "+strings.Join(args, " "))
+ runtime.LogInfo(a.ctx, "mongodump stdout: "+stdout.String())
+ runtime.LogInfo(a.ctx, "mongodump sterr: "+stderr.String())
+ if err != nil {
+ runtime.LogWarning(a.ctx, "Error while executing mongodump: "+err.Error())
}
default:
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
- Title: "Unrecognised export type",
- Message: string(info.Type),
+ Title: "Unrecognised export file type",
+ Message: string(info.FileType),
})
return false
}