From 327b0b5a2119ae888c812f682b3934061b8f59bf Mon Sep 17 00:00:00 2001 From: hmhealey Date: Thu, 15 Oct 2015 15:09:40 -0400 Subject: Added an initial call to get all user preferences on page load --- store/sql_preference_store.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'store/sql_preference_store.go') 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 +} -- cgit v1.2.3-1-g7c22