Search (#36)
First implementation of search functionality for remote account and status lookups.
This commit is contained in:
@ -45,8 +45,9 @@ func (e ErrAlreadyExists) Error() string {
|
||||
}
|
||||
|
||||
type Where struct {
|
||||
Key string
|
||||
Value interface{}
|
||||
Key string
|
||||
Value interface{}
|
||||
CaseInsensitive bool
|
||||
}
|
||||
|
||||
// DB provides methods for interacting with an underlying database or other storage mechanism (for now, just postgres).
|
||||
|
@ -223,7 +223,12 @@ func (ps *postgresService) GetWhere(where []db.Where, i interface{}) error {
|
||||
|
||||
q := ps.conn.Model(i)
|
||||
for _, w := range where {
|
||||
q = q.Where("? = ?", pg.Safe(w.Key), w.Value)
|
||||
if w.CaseInsensitive {
|
||||
q = q.Where("LOWER(?) = LOWER(?)", pg.Safe(w.Key), w.Value)
|
||||
} else {
|
||||
q = q.Where("? = ?", pg.Safe(w.Key), w.Value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if err := q.Select(); err != nil {
|
||||
@ -1143,7 +1148,6 @@ func (ps *postgresService) GetNotificationsForAccount(accountID string, limit in
|
||||
|
||||
q := ps.conn.Model(¬ifications).Where("target_account_id = ?", accountID)
|
||||
|
||||
|
||||
if maxID != "" {
|
||||
n := >smodel.Notification{}
|
||||
if err := ps.conn.Model(n).Where("id = ?", maxID).Select(); err != nil {
|
||||
|
Reference in New Issue
Block a user