使用NeDB引用另一个文档(SQL风格的联接)

我在NeDB有一堆文件,让我们来看看这个forms:

{ _id : "3HDl4vDjQhcWvM76", type : "customer", name : "Bob" }, { _id : "65byNNj7578B9hyu", type : "action", customer : "3HDl4vDjQhcWvM76", ... }, 

(所以一个'行动'引用一个'客户')

而且我想要做一些事情,比如列出所有的行为以及他们的客户名字。 明显的做法是:

 db.find({ type: 'action' }, function (err, actions) { actions.forEach(function(action) { db.findOne({ type: 'customer', _id : action.customer }, function (err, customer) { console.log(action, customer.name); }); }); }); 

但是,这很快就会变得痛苦。 有没有更好的方法来做到这一点? 就像是:

 db.find({ type: 'action' }, {join : ["customer"]}, function (err, actions) { console.log(action, action.customer.name); }); 

会很棒。

这似乎是一个非常普遍的事情要做,但我似乎无法find任何信息。

谢谢!