From 2dc9fc1626507bb54417fc4a1920b847cafb27a2 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 25 Aug 2021 15:34:33 +0200 Subject: Pg to bun (#148) * start moving to bun * changing more stuff * more * and yet more * tests passing * seems stable now * more big changes * small fix * little fixes --- internal/oauth/clientstore.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'internal/oauth/clientstore.go') diff --git a/internal/oauth/clientstore.go b/internal/oauth/clientstore.go index 2e7e0ae88..a642f6cfa 100644 --- a/internal/oauth/clientstore.go +++ b/internal/oauth/clientstore.go @@ -39,10 +39,8 @@ func NewClientStore(db db.Basic) oauth2.ClientStore { } func (cs *clientStore) GetByID(ctx context.Context, clientID string) (oauth2.ClientInfo, error) { - poc := &Client{ - ID: clientID, - } - if err := cs.db.GetByID(clientID, poc); err != nil { + poc := &Client{} + if err := cs.db.GetByID(ctx, clientID, poc); err != nil { return nil, err } return models.New(poc.ID, poc.Secret, poc.Domain, poc.UserID), nil @@ -55,19 +53,19 @@ func (cs *clientStore) Set(ctx context.Context, id string, cli oauth2.ClientInfo Domain: cli.GetDomain(), UserID: cli.GetUserID(), } - return cs.db.UpdateByID(id, poc) + return cs.db.Put(ctx, poc) } func (cs *clientStore) Delete(ctx context.Context, id string) error { poc := &Client{ ID: id, } - return cs.db.DeleteByID(id, poc) + return cs.db.DeleteByID(ctx, id, poc) } // Client is a handy little wrapper for typical oauth client details type Client struct { - ID string `pg:"type:CHAR(26),pk,notnull"` + ID string `bun:"type:CHAR(26),pk,notnull"` Secret string Domain string UserID string -- cgit v1.2.3