summaryrefslogtreecommitdiffstats
path: root/store/sql_preference_store.go
diff options
context:
space:
mode:
authorAsaad Mahmood <Unknowngi@live.com>2015-10-16 18:06:40 +0500
committerAsaad Mahmood <Unknowngi@live.com>2015-10-16 18:06:40 +0500
commit0fbe63eb37b0764a106b0fdd47bc149f122b520d (patch)
tree77cadc54d3a8d0e7812e69c50628cc7f3c5d71b7 /store/sql_preference_store.go
parentb00ffa83e7371fa7dd4570130ee8b506943aee01 (diff)
parent89716cb046ee3c8f13b361053d91149f5ce29cbf (diff)
downloadchat-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.go29
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
+}