2017-03-20 9 views
0

안녕하세요. 내 자신의 페이지 매김을 구현하려고하는데 게시 쿼리를 제한하려고 할 때 다음과 같은 오류가 발생합니다.게시 제한 내역

Exception from sub Products id Xbd4EW32oob8fBPkk Error: must use ordered observe (ie, 'addedBefore' instead of 'added') with skip or limit

Meteor.publish('Products', function(user, options) { 
      if (organization && organization.categories) { 
       //find products in array of categories 
       let products = Products.find({ 
           categories: { 
             '$in': organization.categories 
           }      
          }, 
          {limit: 10} 
          ); 
       return products; 
      } else { 
       return []; 
      } 
     }); 

구독 번호 :

Router.route('/products', { 
    name: 'products', 
    loadingTemplate: 'loading', 

    waitOn: function() { 
     // return one handle, a function, or an array 
     return Meteor.subscribe('Products', {limit: 10}); 
    }, 

    data: function() { 
     return Products.find({}); 
    }, 

    action: function() { 
     this.render('ProductCatalog'); 
    } 

}); 

전체 오류 추적 :

I20170320-16:29:58.231(0)? Exception from sub Products id vDz4GLRXJ6s3cENeE Error: must use ordered observe (ie, 'addedBefore' instead of 'added') with skip or limit 
I20170320-16:29:58.233(0)?  at [object Object]._.extend.observeChanges (packages/minimongo/minimongo.js:325:13) 
I20170320-16:29:58.234(0)?  at [object Object].<anonymous> (packages/omknee:sales-process/sales-process.js:38:31) 
I20170320-16:29:58.235(0)?  at [object Object]._handler (packages/omknee:access-control/access-control.js:38:31) 
I20170320-16:29:58.236(0)?  at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1737:12) 
I20170320-16:29:58.236(0)?  at [object Object]._.extend._runHandler (packages/ddp-server/livedata_server.js:1035:17) 
I20170320-16:29:58.237(0)?  at [object Object]._.extend._startSubscription (packages/ddp-server/livedata_server.js:853:9) 
I20170320-16:29:58.238(0)?  at [object Object]._.extend.protocol_handlers.sub (packages/ddp-server/livedata_server.js:625:12) 
I20170320-16:29:58.239(0)?  at packages/ddp-server/livedata_server.js:559:43 
I20170320-16:29:58.246(0)? Auth Strategy - Local. User : {"user":{"email":"[email protected]"},"password":{"digest":"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8","algorithm":"sha-256"}} 
+0

어딘가에서 커서를 '관찰'하는 것처럼 보입니다. 그 코드도 게시 할 수 있습니까? – jordanwillis

+0

@jordanwillis 내 앱에서 아무 곳이나 관찰을 사용하지 않고 있습니다. – MMrj

+0

사용중인 유성 버전은 무엇입니까? – jordanwillis

답변

1

당신은 (일반적으로 limitsort 함께 사용)하여 찾기 옵션 sort을 추가 할 수 있습니다 어쨌든 있나요 . 이것이 내가이 권고를하는 이유입니다.

커서를 게시하면 Meteor는 자동으로 해당 쿼리에 observe을 설정하여 변경 사항을 구독자에게 보낼 수 있습니다. 그러나 쿼리가 정렬되면 유성은 자동으로 observeChanges을 설정합니다. 이 차이가 오류의 원인이라고 생각합니다. Meteor는 'observeChanges'대신 'observe'를 사용했습니다.

이 상황에 대해 유성에 관한 일부 문제 (예 : #2766#1643)가 기록 된 것으로 확인되었지만 해결 방법을 찾지 못했습니다.

sort 옵션을 추가해야하는 또 다른 이유는 Meteor won't be able to use the oplog for this query입니다.

말했다 모두와 함께

If your query has a limit but not a sort specifier, your query can't take advantage of oplog

, 나는 이런 일이 무엇을 추측하고있어, 위의 오류를 얻고있는 이유 정확히를 정확히하지만, 주어진 수 없습니다.

+0

{sort : {name : 1}, limit : 10} 다음과 같은 옵션으로 동일한 오류가 발생합니다. – MMrj

+1

흠 .. 내가 이것을 알아낼 수 있는지 보아라. – jordanwillis

+0

@MMrj'packages/omknee : sales-process/sales-process.js'에 대한 코드를 게시 할 수 있습니까? – jordanwillis