0
让说我有这个数组有效的方式来找到MongoDB中的数组元素不
const testItems = ['a', 'b', 'c'];
和MongoDB的集合,如
const Cart = new Meteor.Collection('cart');
//{
// _id: String,
// items: [String]
//}
可能是什么一种有效的方法来检查的testItems
哪些要素没有来自该集合的任何阵列items
的任何记录?
我幼稚的方法是通过迭代
const missingItems = testItems.filter(item => !Cart.findOne({ 'items': item }));
去,但有这将需要更少的I/O的方法吗?