diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-10-15 15:09:40 -0400 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-10-15 15:17:07 -0400 |
commit | 327b0b5a2119ae888c812f682b3934061b8f59bf (patch) | |
tree | d2b91e8649a68ec0b87e4e7349d29965a664b43a /store/sql_preference_store.go | |
parent | 4b99e1714029689f27ebf4cb078c60367b0594a4 (diff) | |
download | chat-327b0b5a2119ae888c812f682b3934061b8f59bf.tar.gz chat-327b0b5a2119ae888c812f682b3934061b8f59bf.tar.bz2 chat-327b0b5a2119ae888c812f682b3934061b8f59bf.zip |
Added an initial call to get all user preferences on page load
Diffstat (limited to 'store/sql_preference_store.go')
-rw-r--r-- | store/sql_preference_store.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/store/sql_preference_store.go b/store/sql_preference_store.go index 46cef38b1..7a0fe2f2e 100644 --- a/store/sql_preference_store.go +++ b/store/sql_preference_store.go @@ -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 +} |