diff --git a/data/dataclient.go b/data/dataclient.go index df6fe32..c4be53e 100644 --- a/data/dataclient.go +++ b/data/dataclient.go @@ -90,7 +90,24 @@ func (d *DataClient) InsertTransactions(transactions []models.Transaction) ([]mo return rowsInserted, errors.New("Impossible d'insérer une transaction sans membre_id") } - rows, err := tx.NamedQuery("INSERT INTO transactions (membre_id, given_at, is_perpetual) VALUES (:membre_id, current_timestamp, :is_perpetual) RETURNING id, membre_id, is_perpetual;", &transaction) + rows, err := tx.NamedQuery(` +INSERT INTO + transactions ( + membre_id, + given_at, + is_perpetual + ) +VALUES + ( + :membre_id, + current_timestamp, + :is_perpetual + ) +RETURNING + id, + membre_id, + is_perpetual; +`, &transaction) if err != nil { return rowsInserted, err } @@ -117,8 +134,16 @@ func (d *DataClient) InsertTransactions(transactions []models.Transaction) ([]mo func (d *DataClient) GetTransaction(membreID string, is_perpetual bool) (models.Transaction, error) { var transaction models.Transaction - //err := d.DB.NamedQuery("SELECT * FROM transactions WHERE membre_id=:membre_id AND is_perpetual=:is_perpetual LIMIT 1;" - err := d.DB.Get(&transaction, "SELECT * FROM transactions WHERE membre_id = $1 AND is_perpetual = $2 LIMIT 1;", membreID, is_perpetual) + err := d.DB.Get(&transaction, ` +SELECT + * +FROM + transactions +WHERE + membre_id = $1 AND + is_perpetual = $2 +LIMIT 1; +`, membreID, is_perpetual) if err != nil { return transaction, err } @@ -132,7 +157,13 @@ func (d *DataClient) GetTransaction(membreID string, is_perpetual bool) (models. func (d *DataClient) ListTransactions() ([]models.Transaction, error) { var transactions []models.Transaction - if err := d.DB.Select(&transactions, "SELECT * FROM transactions LIMIT 20000;"); err != nil { + if err := d.DB.Select(&transactions, ` +SELECT + * +FROM + transactions +LIMIT 20000; +`); err != nil { return transactions, err }