Exemplo n.º 1
0
func (um *UserManager) getUserSearchCount(searchText, query string, count chan int) {
	params := url.Values{}
	params.Add("key", util.QuotifyString(searchText))
	userDb := Connection.SelectDB("_users", AdminAuth)
	cr := CountResponse{}
	err := userDb.GetView("user_queries", query, &cr, &params)
	if err == nil && len(cr.Rows) > 0 {
		count <- cr.Rows[0].Value
	} else {
		log.Printf("Error reading search count: %v", err)
		count <- 0
	}
}
Exemplo n.º 2
0
func (um *UserManager) searchUsers(numRecords int, skip int,
	searchText string, query string, ulrChan chan *UserListQueryResponse) {
	params := url.Values{}
	//	params.Add("startkey", util.QuotifyString(searchText))
	//	params.Add("endkey", util.QuotifyString(searchText+"Z"))
	params.Add("key", util.QuotifyString(searchText))
	params.Add("reduce", "false")
	params.Add("limit", strconv.Itoa(numRecords))
	params.Add("skip", strconv.Itoa(skip))
	userDb := Connection.SelectDB("_users", AdminAuth)
	ulr := UserListQueryResponse{}
	err := userDb.GetView("user_queries", query, &ulr, &params)
	if err == nil {
		ulrChan <- &ulr
	} else {
		log.Printf("Error in search query: %v", err)
		ulrChan <- nil
	}
}