// Search a Client by its condition(s) func (s *ClientStore) Search( q store.Query) store.Result { return upperio.NewResult(func() (res db.Result, err error) { // get collection coll, err := s.Coll() if err != nil { return } // retrieve entities by given query conditions conds := upperio.Conds(q.GetConds()) if conds == nil { res = coll.Find() } else { res = coll.Find(conds) } // add sorting information, if any res = res.Sort(upperio.Sort(q)...) // handle paging if q.GetOffset() != 0 { res = res.Skip(uint(q.GetOffset())) } if q.GetLimit() != 0 { res = res.Limit(uint(q.GetLimit())) } return }) }