From 25e8eb9eef2e19d48d3c7b10a5d6f0ddd772e0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Tue, 3 Mar 2020 15:51:18 +0100 Subject: [PATCH] Documenting sql store license methods (#13896) * Documenting sql store license methods * Update store/sqlstore/license_store.go Co-Authored-By: Justine Geffen * Update store/sqlstore/license_store.go Co-Authored-By: Justine Geffen * Update store/sqlstore/license_store.go Co-Authored-By: Justine Geffen * Addressing PR comments * Update store/sqlstore/license_store.go Co-Authored-By: Justine Geffen Co-authored-by: Justine Geffen Co-authored-by: mattermod --- store/sqlstore/license_store.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/store/sqlstore/license_store.go b/store/sqlstore/license_store.go index 789c97599d..7200f5f2cd 100644 --- a/store/sqlstore/license_store.go +++ b/store/sqlstore/license_store.go @@ -10,6 +10,8 @@ import ( "github.com/mattermost/mattermost-server/v5/store" ) +// SqlLicenseStore encapsulates the database writes and reads for +// model.LicenseRecord objects. type SqlLicenseStore struct { SqlStore } @@ -29,6 +31,12 @@ func newSqlLicenseStore(sqlStore SqlStore) store.LicenseStore { func (ls SqlLicenseStore) createIndexesIfNotExists() { } +// Save validates and stores the license instance in the database. The Id +// and Bytes fields are mandatory. The Bytes field is limited to a maximum +// of 10000 bytes. If the license ID matches an existing license in the +// database it returns the license stored in the database. If not, it saves the +// new database and returns the created license with the CreateAt field +// updated. func (ls SqlLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, *model.AppError) { license.PreSave() if err := license.IsValid(); err != nil { @@ -46,6 +54,9 @@ func (ls SqlLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseReco return &storedLicense, nil } +// Get obtains the license with the provided id parameter from the database. +// If the license doesn't exist it returns a model.AppError with +// http.StatusNotFound in the StatusCode field. func (ls SqlLicenseStore) Get(id string) (*model.LicenseRecord, *model.AppError) { obj, err := ls.GetReplica().Get(model.LicenseRecord{}, id) if err != nil {