summaryrefslogtreecommitdiffstats
path: root/store/sqlstore/plugin_store.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/sqlstore/plugin_store.go')
-rw-r--r--store/sqlstore/plugin_store.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/store/sqlstore/plugin_store.go b/store/sqlstore/plugin_store.go
index 23b355f48..e4b79e54a 100644
--- a/store/sqlstore/plugin_store.go
+++ b/store/sqlstore/plugin_store.go
@@ -12,6 +12,10 @@ import (
"github.com/mattermost/mattermost-server/store"
)
+const (
+ DEFAULT_PLUGIN_KEY_FETCH_LIMIT = 10
+)
+
type SqlPluginStore struct {
SqlStore
}
@@ -92,3 +96,23 @@ func (ps SqlPluginStore) Delete(pluginId, key string) store.StoreChannel {
}
})
}
+
+func (ps SqlPluginStore) List(pluginId string, offset int, limit int) store.StoreChannel {
+ if limit <= 0 {
+ limit = DEFAULT_PLUGIN_KEY_FETCH_LIMIT
+ }
+
+ if offset <= 0 {
+ offset = 0
+ }
+
+ return store.Do(func(result *store.StoreResult) {
+ var keys []string
+ _, err := ps.GetReplica().Select(&keys, "SELECT PKey FROM PluginKeyValueStore WHERE PluginId = :PluginId order by PKey limit :Limit offset :Offset", map[string]interface{}{"PluginId": pluginId, "Limit": limit, "Offset": offset})
+ if err != nil {
+ result.Err = model.NewAppError("SqlPluginStore.List", "store.sql_plugin_store.list.app_error", nil, fmt.Sprintf("plugin_id=%v, err=%v", pluginId, err.Error()), http.StatusInternalServerError)
+ } else {
+ result.Data = keys
+ }
+ })
+}