Update try
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user