2016-10-21 3 views
1

JS 엔진없이 감소 실행할 수 없습니다, 나는 몇 가지 쿼리 맵리 듀스를 사용하고 싶습니다하지만 난이 오류가있어 :MongoDB를지도 내가 서비스로 MongoDB를 함께 appcloud에 nodejs 응용 프로그램을 배포

2016년 10월 21일 15 : 45:52 [APP/0] ERR ERR! {[MongoError : js 엔진없이지도를 축소 할 수 없습니다]

swisscom appcloud에서 지원 되는가 또는 무엇인가요? 당신은 스위스 콤의 도커 기반 MongoDB의 서비스를 사용하는

'use strict'; 
 

 
const mongo = require('../mongoclient'); 
 
const paramsParser = require('../paramsParser'); 
 
const log = require('npmlog'); 
 
const faker = require('faker'); 
 
const _ = require('lodash'); 
 

 
const datapoints = function (router) { 
 

 
    const map = function() { 
 
    var payload = this.payload; 
 
    if (payload) { 
 
     payload = payload.toLowerCase().split(" "); 
 
     for (var i = payload.length - 1; i >= 0; i--) { 
 
     payload[i] = payload[i].replace(/[^\w\s]|_/g, "").replace(/\s+/g, " "); 
 
     if (payload[i] && payload[i].length > 7) { 
 
      emit(payload[i], 1); // store a 1 for each word 
 
     } 
 
     } 
 
    } 
 
    } 
 

 
    const reduce = function(key, values) { 
 
    var count = 0; 
 
    values.forEach(function (v) { 
 
     count += v; 
 
    }); 
 
    return count; 
 
    } 
 
    
 
    router.get('/counts', function (req, res) { 
 
    const filters = paramsParser.parse(req.query); 
 

 
    mongo.mapReduce(map, reduce, filters) 
 
     .then(function (data) { 
 
     const topics = data 
 
      .sort((a, b) => b.value - a.value) 
 
      .slice(0, 10) 
 
      .map(function(topic) { 
 
      return { id: faker.random.uuid(), title: topic._id, score: topic.value } 
 
      }); 
 
     res.json(topics); 
 
     }) 
 
     .catch(function(err) { 
 
     log.error(err); 
 
     res.sendStatus(500); 
 
     }); 
 
    }); 
 

 
}; 
 

 
module.exports = datapoints;

function mapReduce(map, reduce, filters) { 
 
    filters = filters ? filters : defaults; 
 
    return new Promise(function(resolve, reject) { 
 
    client.connect(uri(), function(err, db) { 
 
     db.collection(collection) 
 
     .mapReduce(map, reduce, { out: { inline: 1 }, query: filters.find, limit: filters.pageSize }, function(err, docs) { 
 
      if (err) { 
 
      reject(err); 
 
      } 
 
      resolve(docs); 
 
     }); 
 
    }); 
 
    }); 
 
}

답변

2

:

내 컨트롤러 (추출물)입니다.

는 스위스 콤은 스위스 콤 때문에 보안의 플래그를 활성화 security.javascriptEnabled

Enables or disables the server-side JavaScript execution. When disabled, you cannot use operations that perform server-side execution of JavaScript code, such as the $where query operator, mapReduce command and the db.collection.mapReduce() method, group command and the db.collection.group() method.

으로 mongod를 시작했다. MongoDB를 강화하는 가장 좋은 방법입니다. Swisscom은 기술적 논증과 토론에 대해 열려 있습니다. 아마도 Swisscom은 중요한 사실을 놓친 것입니까?

security: 
    authorization: enabled 
    javascriptEnabled: false 

Swisscom은 다른 MongoDB 서비스 (도커 컨테이너에는 복제가없는 3 개의 전용 VM)를 제공합니다. 거기에이 제한이 없습니다.

$ cf m -s mongodbent 
Getting service plan information for service mongodbent as admin... 
OK 

service plan description                         free or paid 
small3rs  Replica Set with 3 data bearing nodes with 32 GB memory, 320 GB storage, unlimited concurrent connections paid 
medium3rs  Replica Set with 3 data bearing nodes with 48 GB memory, 480 GB storage, unlimited concurrent connections paid 
large3rs  Replica Set with 3 data bearing nodes with 64 GB memory, 640 GB storage, unlimited concurrent connections paid 

이 계획을 사용하면 엔터프라이즈 버전의 MongoDB를 받고 Ops Manager에 액세스 할 수 있습니다. Ops Manager에서 MongoDB 메트릭으로 멋진 HTML5 그래프를 볼 수 있습니다. 역사가있는 db.runCommand({ serverStatus: 1 })의 멋진 GUI 프론트 엔드입니다.

관련 문제