func (s SqlCommandStore) Save(command *model.Command) StoreChannel { storeChannel := make(StoreChannel) go func() { result := StoreResult{} if len(command.Id) > 0 { result.Err = model.NewLocAppError("SqlCommandStore.Save", "store.sql_command.save.saving_overwrite.app_error", nil, "id="+command.Id) storeChannel <- result close(storeChannel) return } command.PreSave() if result.Err = command.IsValid(); result.Err != nil { storeChannel <- result close(storeChannel) return } if err := s.GetMaster().Insert(command); err != nil { result.Err = model.NewLocAppError("SqlCommandStore.Save", "store.sql_command.save.saving.app_error", nil, "id="+command.Id+", "+err.Error()) } else { result.Data = command } storeChannel <- result close(storeChannel) }() return storeChannel }