任何人都可以在c9.io中给我一个mongodb连接URL的例子吗?我想连接到他们当地的mongodb实例,我有mongod在后台运行。
以下是我正在尝试使用的内容:
# explore the legend route
# add to legend rather than replace
dyG %>%
dyCallbacks(
highlightCallback = sprintf(
'function(e, x, pts, row) {
// added to illustrate what is happening
// remove once satisfied with your code
debugger;
var customLegend = %s
// should get our htmlwidget
var legendel = e.target.parentNode.parentNode
.querySelectorAll(".dygraph-legend")[0];
// should get our htmlwidget
legendel.innerHTML = legendel.innerHTML + "<br>" + customLegend[row];
}'
,# supply a vector or text that you would like
jsonlite::toJSON(rep('something here',length(as.vector(presidents))))
)
)
它甚至没有记录,任何帮助都会非常感激。
答案 0 :(得分:0)
我得到了这个工作我的逻辑有点偏离:p
function OpenDB(mongoUrl, callBack){
var MongoClient = mongodb.MongoClient;
//var url = 'mongodb://localhost:27017/my_database_name';
var url = mongoUrl || "mongodb://" + process.env.IP + "/test";
console.log(url.bgWhite.blue);
// Use connect method to connect to the Server
MongoClient.connect(url, function(err, db) {
if(err){
console.log(err);
}
console.log("Connected correctly to server");
callBack(db);
db.close();
});
}