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

Updates to update screen

- Code example for update
- Nice default operators
- Fixed memory leak
This commit is contained in:
2023-01-18 13:38:31 +01:00
parent 07a17669c5
commit af72f76350
2 changed files with 43 additions and 22 deletions

View File

@ -56,7 +56,8 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
for _, param := range form.Parameters {
var unmarshalled bson.M
if json.Unmarshal([]byte(param.Value), &unmarshalled) == nil {
err = json.Unmarshal([]byte(param.Value), &unmarshalled)
if err == nil {
update[param.Type] = unmarshalled
} else {
fmt.Println(err.Error())
@ -72,8 +73,6 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
var result *mongo.UpdateResult
options := mongoOptions.Update().SetUpsert(form.Upsert)
fmt.Println(query, update)
if form.Many {
result, err = client.Database(dbKey).Collection(collKey).UpdateMany(ctx, query, update, options)
} else {