1

I am trying to save documents using pouchdb's bulkSave() function. However, when these documents are saved it starts to sync with master database using sync gateway & in doing so the webapp slows down and when I try to navigate to different tabs no content is displayed on that tab.

Below is an example of how the documents are being created:

for (var i = 0; i <= instances; i++) {
      if (i > 0) {
        advTask.startDate = new Date(new Date(advTask.startDate).setHours(new Date(advTask.startDate).getHours() + offset));
      }
      if (advTask.estimatedDurationUnit == 'Minutes') {
        advTask = $Date.getAdvTaskEndTimeIfMinutes(advTask);
      } else if (advTask.estimatedDurationUnit == 'Hours') {
        advTask = $Date.getAdvTaskEndTimeIfHours(advTask);
      } else if (advTask.estimatedDurationUnit == 'Days') {
        advTask = $Date.getAdvTaskEndTimeIfDays(advTask);
      }
        if(new Date(advTask.endDate).getTime() >= new Date($scope.advTask.endDate).getTime()) {
          // here save the task array using bulkSave() function
          $db.bulkSave(tasks).then(function (res) {
            $db.sync();
          });
          break;
        }
        advTask.startDate = $Date.toGMT(advTask.startDate);
        advTask.endDate = $Date.toGMT(advTask.endDate);
        var adv = angular.copy(advTask);
        tasks.push(adv); // here pushing the documents to an array
        offset = advTask.every;
    }

Thanks in advance!

ajinkya udgirkar
  • 223
  • 1
  • 10

1 Answers1

0

bulkSave is not a core PouchDB API; are you using a plugin?

Also one piece of advice I'd give is that Couchbase Sync Gateway does not have 100% support for PouchDB and is known to be problematic in some cases.

Another piece of advice is that running PouchDB in a web worker can prevent your UI thread from getting overloaded, which would fix the problem of tabs not showing up.

Do you have a live test case to demonstrate?

nlawson
  • 11,510
  • 4
  • 40
  • 50