mirror of
https://github.com/pushbits/server.git
synced 2025-05-24 14:26:35 +02:00
Implement deletion of users
This commit is contained in:
parent
18d11677ac
commit
f6ca287d0b
10 changed files with 112 additions and 35 deletions
|
@ -18,31 +18,28 @@ func (d *Database) DeleteApplication(application *model.Application) error {
|
|||
return d.gormdb.Delete(application).Error
|
||||
}
|
||||
|
||||
// UpdateApplication updates an application.
|
||||
func (d *Database) UpdateApplication(app *model.Application) error {
|
||||
return d.gormdb.Save(app).Error
|
||||
}
|
||||
|
||||
// GetApplicationByID returns the application for the given ID or nil.
|
||||
// GetApplicationByID returns the application with the given ID or nil.
|
||||
func (d *Database) GetApplicationByID(ID uint) (*model.Application, error) {
|
||||
app := new(model.Application)
|
||||
var app model.Application
|
||||
|
||||
err := d.gormdb.First(&app, ID).Error
|
||||
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return app, err
|
||||
return &app, err
|
||||
}
|
||||
|
||||
// GetApplicationByToken returns the application for the given token or nil.
|
||||
// GetApplicationByToken returns the application with the given token or nil.
|
||||
func (d *Database) GetApplicationByToken(token string) (*model.Application, error) {
|
||||
app := new(model.Application)
|
||||
err := d.gormdb.Where("token = ?", token).First(app).Error
|
||||
var app model.Application
|
||||
|
||||
err := d.gormdb.Where("token = ?", token).First(&app).Error
|
||||
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return app, err
|
||||
return &app, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue