How does LiveQuery work

Hello,

I'm trying to create a live query that is filtered using a startKey and endKey. I'd like to show data by day. The startKey is the start of a given day and the endKey is the end of of that day. I want the Android user to be able to change the selected day and see data for any desired day.

I'm not sure, but I'm under the impression that the LiveQuery is compiled and stored with the initial provided date range. Is it true that dates used in a LiveQuery cannot be changed unless the Query is updated? I often see a message that the query did not require re compile. Should I continually be updating the query by updating the version number? I'm pretty confused as to how to use the live query. Some more explanation or a link is very appreciated.

When I create the live query tailored for a user with their required selection filter, is that query only used for that one user. Or is this LiveQuery / view somehow shared by other users?

Thanks
Brian

1 Answer

« Back to question.

>I'm not sure, but I'm under the impression that the LiveQuery is compiled and stored with the initial provided date range.

Yes.

>Is it true that dates used in a LiveQuery cannot be changed unless the Query is updated?

Yes.

>I often see a message that the query did not require re compile. Should I continually be updating the query by updating the version number?

You're mixing up queries and views. It's the view that has a version number, and the view that builds an index. A query is just a request for a range of key/value pairs from the view's index.

You'll build a view once that indexes documents by date. Then when you want to see docs for a given date range, you'll create a query (live or not) and run it. To see a different date range you build another query, but you don't need to update the view.

Thanks a lot. I got it running.