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
This commit is contained in:
tobi 2021-08-25 15:34:33 +02:00 committed by GitHub
commit 2dc9fc1626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
713 changed files with 98694 additions and 22704 deletions

View file

@ -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