diff options
author | Asaad Mahmood <Unknowngi@live.com> | 2015-10-16 18:06:40 +0500 |
---|---|---|
committer | Asaad Mahmood <Unknowngi@live.com> | 2015-10-16 18:06:40 +0500 |
commit | 0fbe63eb37b0764a106b0fdd47bc149f122b520d (patch) | |
tree | 77cadc54d3a8d0e7812e69c50628cc7f3c5d71b7 /store/sql_preference_store.go | |
parent | b00ffa83e7371fa7dd4570130ee8b506943aee01 (diff) | |
parent | 89716cb046ee3c8f13b361053d91149f5ce29cbf (diff) | |
download | chat-0fbe63eb37b0764a106b0fdd47bc149f122b520d.tar.gz chat-0fbe63eb37b0764a106b0fdd47bc149f122b520d.tar.bz2 chat-0fbe63eb37b0764a106b0fdd47bc149f122b520d.zip |
Merge branch 'master' of https://github.com/mattermost/platform into ui-improvements
Diffstat (limited to 'store/sql_preference_store.go')
-rw-r--r-- | store/sql_preference_store.go | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/store/sql_preference_store.go b/store/sql_preference_store.go index 46cef38b1..bf6e030bf 100644 --- a/store/sql_preference_store.go +++ b/store/sql_preference_store.go @@ -43,7 +43,7 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) StoreChannel { result := StoreResult{} // wrap in a transaction so that if one fails, everything fails - transaction, err := s.GetReplica().Begin() + transaction, err := s.GetMaster().Begin() if err != nil { result.Err = model.NewAppError("SqlPreferenceStore.Save", "Unable to open transaction to save preferences", err.Error()) } else { @@ -212,3 +212,30 @@ func (s SqlPreferenceStore) GetCategory(userId string, category string) StoreCha return storeChannel } + +func (s SqlPreferenceStore) GetAll(userId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + var preferences model.Preferences + + if _, err := s.GetReplica().Select(&preferences, + `SELECT + * + FROM + Preferences + WHERE + UserId = :UserId`, map[string]interface{}{"UserId": userId}); err != nil { + result.Err = model.NewAppError("SqlPreferenceStore.GetAll", "We encounted an error while finding preferences", err.Error()) + } else { + result.Data = preferences + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} |