feat(expense): starting expense handle
This commit is contained in:
@@ -6,6 +6,30 @@ type Database struct {
|
||||
*postgresql.DatabasePostgreSQL
|
||||
}
|
||||
|
||||
func (d Database) GetAllExpensesOfAnAccount(id string) (interface{}, interface{}) {
|
||||
q := `
|
||||
SELECT a.id, a.user_id, a.name, a.provider, a.created_at, a.updated_at
|
||||
FROM public.account a
|
||||
WHERE a.user_id = $1
|
||||
`
|
||||
rows, err := db.Session.Query(q, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
as := make([]*Account, 0)
|
||||
for rows.Next() {
|
||||
a := Account{}
|
||||
err := rows.Scan(&a.ID, &a.UserId, &a.Name, &a.Provider, &a.CreatedAt, &a.UpdatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
as = append(as, &a)
|
||||
}
|
||||
return as, nil
|
||||
}
|
||||
|
||||
func NewDatabase(db *postgresql.DatabasePostgreSQL) *Database {
|
||||
return &Database{db}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user