Update try

This commit is contained in:
mr
2026-03-02 15:46:05 +01:00
parent cb3771c17a
commit 44812309db
19 changed files with 64 additions and 80 deletions

View File

@@ -48,16 +48,14 @@ func (a *workspaceMongoAccessor) DeleteOne(id string) (utils.DBObject, int, erro
}
// UpdateOne updates a workspace in the database, given its ID, it automatically share to peers if the workspace is shared
func (a *workspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
d := set.(*Workspace) // Get the workspace from the set
d.Clear()
if d.Active { // If the workspace is active, deactivate all the other workspaces
func (a *workspaceMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
if set["active"] == true { // If the workspace is active, deactivate all the other workspaces
res, _, err := a.LoadAll(true)
if err == nil {
for _, r := range res {
if r.GetID() != id {
r.(*Workspace).Active = false
a.UpdateOne(r.(*Workspace), r.GetID())
set["active"] = false
a.UpdateOne(set, r.GetID())
}
}
}