private QueryOptions GetQueryOptions() { QueryOptions queryOptions = new QueryOptions(); queryOptions.SetStartKey(GetStartKey()); queryOptions.SetEndKey(GetEndKey()); queryOptions.SetStartKey(GetStartKey()); queryOptions.SetKeys(GetKeys()); queryOptions.SetSkip(GetSkip()); queryOptions.SetLimit(GetLimit()); queryOptions.SetReduce(!IsMapOnly()); queryOptions.SetReduceSpecified(true); queryOptions.SetGroupLevel(GetGroupLevel()); queryOptions.SetDescending(IsDescending()); queryOptions.SetIncludeDocs(ShouldPrefetch()); queryOptions.SetUpdateSeq(true); queryOptions.SetInclusiveEnd(true); queryOptions.SetStale(GetIndexUpdateMode()); queryOptions.SetAllDocsMode(GetAllDocsMode()); queryOptions.SetStartKeyDocId(GetStartKeyDocId()); queryOptions.SetEndKeyDocId(GetEndKeyDocId()); return(queryOptions); }
private QueryOptions GetQueryOptions() { QueryOptions queryOptions = new QueryOptions(); queryOptions.SetStartKey(GetStartKey()); queryOptions.SetEndKey(GetEndKey()); queryOptions.SetStartKey(GetStartKey()); queryOptions.SetKeys(GetKeys()); queryOptions.SetSkip(GetSkip()); queryOptions.SetLimit(GetLimit()); queryOptions.SetReduce(!IsMapOnly()); queryOptions.SetReduceSpecified(true); queryOptions.SetGroupLevel(GetGroupLevel()); queryOptions.SetDescending(IsDescending()); queryOptions.SetIncludeDocs(ShouldPrefetch()); queryOptions.SetUpdateSeq(true); queryOptions.SetInclusiveEnd(true); queryOptions.SetStale(GetIndexUpdateMode()); queryOptions.SetAllDocsMode(GetAllDocsMode()); queryOptions.SetStartKeyDocId(GetStartKeyDocId()); queryOptions.SetEndKeyDocId(GetEndKeyDocId()); return queryOptions; }
/// <summary> /// https://github.com/couchbase/couchbase-lite-android/issues/139 /// test based on https://github.com/couchbase/couchbase-lite-ios/blob/master/Source/CBL_View_Tests.m#L358 /// </summary> /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception> public virtual void TestViewQueryStartKeyDocID() { PutDocs(database); IList<RevisionInternal> result = new AList<RevisionInternal>(); IDictionary<string, object> dict = new Dictionary<string, object>(); dict.Put("_id", "11112"); dict.Put("key", "one"); result.AddItem(PutDoc(database, dict)); View view = CreateView(database); view.UpdateIndex(); QueryOptions options = new QueryOptions(); options.SetStartKey("one"); options.SetStartKeyDocId("11112"); options.SetEndKey("three"); IList<QueryRow> rows = view.QueryWithOptions(options); NUnit.Framework.Assert.AreEqual(2, rows.Count); NUnit.Framework.Assert.AreEqual("11112", rows[0].GetDocumentId()); NUnit.Framework.Assert.AreEqual("one", rows[0].GetKey()); NUnit.Framework.Assert.AreEqual("33333", rows[1].GetDocumentId()); NUnit.Framework.Assert.AreEqual("three", rows[1].GetKey()); options = new QueryOptions(); options.SetEndKey("one"); options.SetEndKeyDocId("11111"); rows = view.QueryWithOptions(options); Log.D(Tag, "rows: " + rows); NUnit.Framework.Assert.AreEqual(3, rows.Count); NUnit.Framework.Assert.AreEqual("55555", rows[0].GetDocumentId()); NUnit.Framework.Assert.AreEqual("five", rows[0].GetKey()); NUnit.Framework.Assert.AreEqual("44444", rows[1].GetDocumentId()); NUnit.Framework.Assert.AreEqual("four", rows[1].GetKey()); NUnit.Framework.Assert.AreEqual("11111", rows[2].GetDocumentId()); NUnit.Framework.Assert.AreEqual("one", rows[2].GetKey()); options.SetStartKey("one"); options.SetStartKeyDocId("11111"); rows = view.QueryWithOptions(options); NUnit.Framework.Assert.AreEqual(1, rows.Count); NUnit.Framework.Assert.AreEqual("11111", rows[0].GetDocumentId()); NUnit.Framework.Assert.AreEqual("one", rows[0].GetKey()); }
public void TestViewQueryStartKeyDocID() { PutDocs(database); var result = new List<RevisionInternal>(); var dict = new Dictionary<string, object>() { {"_id", "11112"}, {"key", "one"} }; result.Add(PutDoc(database, dict)); var view = CreateView(database); view.UpdateIndex(); var options = new QueryOptions(); options.SetStartKey("one"); options.SetStartKeyDocId("11112"); options.SetEndKey("three"); var rows = view.QueryWithOptions(options).ToList<QueryRow>(); Assert.AreEqual(2, rows.Count); Assert.AreEqual("11112", rows[0].DocumentId); Assert.AreEqual("one", rows[0].Key); Assert.AreEqual("33333", rows[1].DocumentId); Assert.AreEqual("three", rows[1].Key); options = new QueryOptions(); options.SetEndKey("one"); options.SetEndKeyDocId("11111"); rows = view.QueryWithOptions(options).ToList<QueryRow>(); Assert.AreEqual(3, rows.Count); Assert.AreEqual("55555", rows[0].DocumentId); Assert.AreEqual("five", rows[0].Key); Assert.AreEqual("44444", rows[1].DocumentId); Assert.AreEqual("four", rows[1].Key); Assert.AreEqual("11111", rows[2].DocumentId); Assert.AreEqual("one", rows[2].Key); options.SetStartKey("one"); options.SetStartKeyDocId("11111"); rows = view.QueryWithOptions(options).ToList<QueryRow>(); Assert.AreEqual(1, rows.Count); Assert.AreEqual("11111", rows[0].DocumentId); Assert.AreEqual("one", rows[0].Key); }