Skip to content
Snippets Groups Projects
Commit 71b3c94262a3 authored by Florent Aide's avatar Florent Aide
Browse files

add DeleteWhere

parent f6841cca7df5
No related branches found
No related tags found
No related merge requests found
Pipeline #63588 failed
......@@ -54,6 +54,7 @@
}
// GetWhere loads a mapped structure
// ex: GetWhere(account, squirrel.Eq{models.AccountDBNameColumn: "somename"})
func (h *SQLHelper) GetWhere(obj Mapped, pred interface{}, args ...interface{}) error {
query := SQ.
Select(obj.Columns(true)...).
......@@ -63,6 +64,17 @@
return h.Get(obj, query)
}
// DeleteWhere deletes from a table corresponding to a mapped structure using the predicate and args
// ex: DeleteWhere(account, squirrel.Eq{models.AccountDBNameColumn: "somename"})
func (h *SQLHelper) DeleteWhere(obj Mapped, pred interface{}, args ...interface{}) error {
query := SQ.
Delete(obj.Table()).
Where(pred, args...)
_, err := h.Exec(query)
return err
}
// GetWhereForUpdate loads a mapped structure and get a lock
// (see https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE)
func (h *SQLHelper) GetWhereForUpdate(obj Mapped, pred interface{}, args ...interface{}) error {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment