Skip to content

Commit 1640fe2

Browse files
committed
Add limit and skip
1 parent a96d456 commit 1640fe2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Bluemix/Bluemix.Cloudant/Search/CloudantSearch.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,24 @@ public CloudantSearch(Datasource ds)
3434
/// </summary>
3535
/// <returns>Search Result Rows.</returns>
3636
/// <param name="dbName">Db name.</param>
37-
/// <param name="searchValue">Search value.</param>
38-
public async Task<SearchResult> SearchById(String searchValue)
37+
/// <param name="SearchValue">Search value.</param>
38+
/// <param name="Limit">Optionally, Keep your result set to a certain size.</param>
39+
/// <param name="Skip">Optionally, If you want to offset your result set (for example to paginate through some rows).</param>
40+
public async Task<SearchResult> SearchById(String SearchValue,int Limit=-1, int Skip=-1)
3941
{
40-
String apiPath = String.Format("/{0}{1}/?keys=[\"{2}\"]",_ds.DatabaseName,primaryIndexURI,searchValue);
42+
String apiPath = String.Format("/{0}{1}/?keys=[\"{2}\"]",_ds.DatabaseName,primaryIndexURI,SearchValue);
43+
if (Limit !=-1)
44+
apiPath += String.Format("&limit={0}",Limit);
45+
if (Skip !=-1)
46+
apiPath += String.Format("&skip={0}",Skip);
47+
4148
Request req = new Request (cloudantConfiguration, apiPath);
4249

4350
var responseMessage = await client.GetAsync(req);
4451
SearchResult retval = JsonConvert.DeserializeObject<SearchResult>(responseMessage);
4552
return retval;
4653
}
54+
4755
/// <summary>
4856
/// Gets the document by identifier.
4957
/// </summary>

0 commit comments

Comments
 (0)