1

我正在使用 Nedb 作为数据库的项目。我需要的是在其他函数中调用数据库内部的变量。我所做的是使用 db.find 从数据库中获取变量,如下所示:

function findvariable(){
var prob=0;
db.find({}, function(err, newDoc) {
prob= newDoc[0].probability;
});
}

那么我如何调用概率变量outide db.find,例如在这样的测试函数内部:

function test{
var a =prob;
console.log(a);// a will get the value of prob
}

有人能帮我吗?

4

0 回答 0