Searching with query

27 views
Skip to first unread message

Raheel Mateen

unread,
Oct 3, 2014, 5:42:53 AM10/3/14
to mobile-c...@googlegroups.com
i have the function which receive the view and run the query like :

public QueryEnumerator findBy( final String fieldName ) {
com.couchbase.lite.View view = createView( fieldName );
Query query = view.createQuery();
Timestamp currentTime = this.currentTime();
if(previousTime == null)
previousTime = currentTime;
query.setStartKey( previousTime );
query.setEndKey( currentTime );
QueryEnumerator rowEnum = null;
try {
rowEnum = query.run();
android.util.Log.d( TAG, rowEnum.toString() );
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
return rowEnum;
}

Now what i am looking is that I want to search only those document which are in between previousTime and currenttime , i dont know how actually i do this , actually i need this -> Select * from abc where date > previousTime

Jens Alfke

unread,
Oct 3, 2014, 11:24:44 AM10/3/14
to mobile-c...@googlegroups.com

On Oct 3, 2014, at 2:42 AM, Raheel Mateen <raheel...@riksof.com> wrote:

Now what i am looking is that I want to search only those document which are in between previousTime and current time

Create a view whose map function emits the timestamp as the key.
Then query with startKey=previousTime and no endKey.

Have your read the View and Query docs?

—Jens
Reply all
Reply to author
Forward
0 new messages