How to sync last 30 days particular documents on Couchbaselite Replication?


#1

Hi, I have different types of model documents. But i want to sync last 30 days particular documents on sync replication.

For example:

Customer, orders, payments like documents i have. i want last 30 days registered users on my sync gateway replication.
is it solution to manipulate synch gateway. if it is which files i have to manipulate?


#2

Hi @itssrinadh,

Here’s a suggestion:

  1. Create a view on SG that indexes documents by their last updated time (this requires to store a timestamp on each document). The key in the emit call should be the timestamp.
  2. Query the view with the start and end key set to the time frame of interest.
  3. I don’t remember if view query results always return the doc id. If not, you can specify it in the emit value. Anyways, once you have the doc IDs, you can provide them to the pull.documentIDs property to only pull those documents.

James


#3

Where i have to create a view. i mean SG. where can i find a SG files and write code for that.