2016-05-15 3 views
0

Debianでmap-reduce JSスクリプトを実行する必要があります:スクリプトはローカル(mongod)で実行されているMongoDBインスタンスを読み書きし、類似のエントリ。
問題はスクリプトが負荷印刷の機能が含まれていることである。Debianでload()とprint()関数を含むJSスクリプトを実行する

load("map-reduce-.../somefile.js"); 


var Db = require('mongodb').Db, 
MongoClient = require('mongodb').MongoClient, 
... 

var db = new Db('results', new Server('localhost', 27017)); 
// Connect to db 
... 

var collectionName = "labelgroups"; //collection to store last executions 
var testset = "testset"; //collection target of map-reduce 
var mapReduceName = "timedmapReduce"; //output collection 

var collection = db.getCollection(collectionName); 
if (collection.exists() == null) { 
    // Create collection 
    print("mapReduce collection is being created"); 
    db.createCollection(collectionName); 
    collection = db.getCollection(collectionName); 
    collection.insert({ ... }); 
} else { ... } 

私はNodeJSを使用してみましたが、私はそれらの機能のためのモジュールをインストールできませんでした。また、Rhinoを使って実行しようとしましたが、Rhinoは印刷機能とロード機能を処理しますが、MongoDBモジュールを処理することはできません。
Debianでこのスクリプトを実行するにはどうすればよいですか?

答えて

0

これにはconsole.log()を使用してください。

例:

console.log('This line will be written to stdout'); 
関連する問題