Просмотр исходного кода

Fix: use cursor() instead of stream() of mongoose

Sotaro KARASAWA 9 лет назад
Родитель
Сommit
edc4cc8a53
2 измененных файлов с 4 добавлено и 4 удалено
  1. 1 1
      lib/models/page.js
  2. 3 3
      lib/util/search.js

+ 1 - 1
lib/models/page.js

@@ -579,7 +579,7 @@ module.exports = function(crowi) {
         {path: 'revision', model: 'Revision'},
       ])
       .sort({updatedAt: -1})
-      .stream();
+      .cursor();
   };
 
   /**

+ 3 - 3
lib/util/search.js

@@ -208,11 +208,11 @@ SearchClient.prototype.addAllPages = function()
   var self = this;
   var offset = 0;
   var Page = this.crowi.model('Page');
-  var stream = Page.getStreamOfFindAll();
+  var cursor = Page.getStreamOfFindAll();
   var body = [];
 
   return new Promise(function(resolve, reject) {
-    stream.on('data', function (doc) {
+    cursor.on('data', function (doc) {
       if (!doc.creator || !doc.revision || !self.shouldIndexed(doc)) {
         debug('Skipped', doc.path);
         return ;
@@ -221,7 +221,7 @@ SearchClient.prototype.addAllPages = function()
       self.prepareBodyForCreate(body, doc);
     }).on('error', function (err) {
       // TODO: handle err
-      debug('Error stream:', err);
+      debug('Error cursor:', err);
     }).on('close', function () {
       // all done