add sqlite server
This commit is contained in:
35
local/repository/api.go
Normal file
35
local/repository/api.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"acc-server-manager/local/model"
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ApiRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewApiRepository(db *gorm.DB) *ApiRepository {
|
||||
return &ApiRepository{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetFirst
|
||||
|
||||
Gets first row from API table.
|
||||
|
||||
Args:
|
||||
context.Context: Application context
|
||||
Returns:
|
||||
model.ApiModel: Api object from database.
|
||||
*/
|
||||
func (as ApiRepository) GetFirst(ctx context.Context) model.ApiModel {
|
||||
db := as.db.WithContext(ctx)
|
||||
apiModel := model.ApiModel{Api: "Works"}
|
||||
db.First(&apiModel)
|
||||
return apiModel
|
||||
}
|
||||
Reference in New Issue
Block a user