Restrict Sync Gateway to replicate documents for last 7 days

Is there any way to update the sync gateway configuration to restrict the replication for last 7 days? I just want to replicate the documents for last 7 days to improve the performance of the app.

My current sync config is as follows:

  "interface": ":4984",
  "profileInterface": "80",
  "adminInterface": ":4985",
  "MaxFileDescriptors": 25000,
  "log": [
  "databases": {
    "db1": {
      "username": "${CB_USER}",
      "password": "${CB_PASS}",
      "bucket": "bucket1",
      "server": "http://db:8091",
      "revs_limit": 100,
      "changes_feed_limit": 200,
      "enable_shared_bucket_access": true,
      "import_docs": "continuous",
      "sync": `
      function(doc, oldDoc) {
        if(doc.type === "type2"||doc.type === "type1") {
        } else {
      "users": {
        "GUEST": { "disabled": false, "admin_channels": ["*"] }

How about you have a job on your app server that moves docs older than 7 days to a separate archive channel that does not get synced by the clients ?
There are couple of options to trigger that - in one option, your job could update the “status” of your older docs to “Archive” and your sync function would use that flag to assign the docs to the archive channel.