2017-01-27 2 views
0

seneca-mongo 저장소 모듈을 사용하여 mongo db에 연결하는 간단한 작업을 작성하고 목록 쿼리를 실행하고 결과를 가져 왔습니다. 쿼리가 성공적이었으며 올바른 결과가 얻어 졌음을 알 수 있습니다. 이러한 결과를 클라이언트에 다시 보내려고하면 다음 메시지 및 스택 추적으로 응답 호출 오류가 발생합니다. 내가 쓴TypeError seneca indexof 응답 중에 함수가 아닌 경우

ERROR  act  root$   OUT    cmd:getparams,role:diff 11  {cmd:getparams,role:diff,payload:{id:scalaScan}} ENTRY (dqk22) -  seneca: Action cmd:getparams,role:diff callback threw: k.indexOf is not a function.  act_callback {message:k.indexOf is not a function,pattern:cmd:getparams,role:diff,instance:Seneca/0.7.2/d0twcki9cmxg/1485517  TypeError: k.indexOf is not a function 
    at /scratch/DiffAnalyzer/node_modules/seneca/node_modules/seneca-web/web.js:851:13 
    at Function.forEach (/scratch/DiffAnalyzer/node_modules/lodash/dist/lodash.js:3298:15) 
    at Object.defaultmodify [as modify] (/scratch/DiffAnalyzer/node_modules/seneca/node_modules/seneca-web/web.js:850:7) 
    at respond (/scratch/DiffAnalyzer/node_modules/seneca/node_modules/seneca-web/web.js:654:22) 
    at Seneca.<anonymous> (/scratch/DiffAnalyzer/node_modules/seneca/node_modules/seneca-web/web.js:401:7) 
    at act_done (/scratch/DiffAnalyzer/node_modules/seneca/seneca.js:1554:16) 
    at /scratch/DiffAnalyzer/node_modules/gate-executor/gate-executor.js:127:20 
    at Seneca.<anonymous> (/scratch/DiffAnalyzer/analyze.js:613:5) 
    at act_done (/scratch/DiffAnalyzer/node_modules/seneca/seneca.js:1554:16) 
    at /scratch/DiffAnalyzer/node_modules/gate-executor/gate-executor.js:127:20 
    at /scratch/DiffAnalyzer/node_modules/seneca-mongo-store/mongo-store.js:329:21 
    at /scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:271:33 
    at /scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:778:35 
    at Cursor.close (/scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:1009:5) 
    at Cursor.nextObject (/scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:778:17) 
    at Cursor.each (/scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:264:12) 

동작은 동일한 코드 조각 작업을 지금은이 오류를 얻고 있었다

seneca.add("role:diff,cmd:getparams", function(msg, respond) { 
    seneca.ready(function() { 
     var collection = seneca.make$("paramStore"); 
     var f = msg.payload; 

     seneca.log.info("Filter", f); 
     collection.list$(f, function(err, ob) { 
      if (err) { 
       seneca.log.error(err); 
       respond(err); 
      } else { 
       seneca.log.info("Result", ob); 
       respond(null, ob); 
      } 
     }); 
    }); 
}); 

입니다. 무엇이 변경되었는지 확실하지 않습니다. 어떤 도움이나 제안이라도 대단히 감사합니다.

답변

0

내가 직면 한 문제 때문에 _.each 기능은 내 경우에는 아웃 실제로이었다 JSON 개체를 구문 분석하기위한 것입니다

if(_.isObject(result.out)) { 
    _.each(result.out,function(v,k){ 
     if(~k.indexOf('$') && 'http$' !== k) { 
     delete result.out[k] 
     } 
    }) 

모듈의 JS 파일에 코드의이 비트이었다 JSON 배열. 배열을 객체로 래핑하면 해결됩니다.

관련 문제