我用咖啡脚本编写node.js,它工作正常,我想知道的是如何在咖啡脚本中返回一个函数的值 ,这里是我的代码如何在咖啡脚本中返回一个函数的值
exports.find=->
db.open((err, db)->
unless err
db.createCollection('test', (err, collection)->
unless err
collection.find().toArray((err, items)->
unless err
//here how to return *items*
console.log(items)
)
)
)
巧,如何在另一个模块中使用这种方法吗? '分贝=要求( './分贝'); items = db.find(???)' – Mil0R3
@Veelian就像你在示例代码中使用'db.open'一样。 'db.find(err,items) - > doSomething(items)' – qiao