res = await db.collection('test-fav').aggregate()
.lookup({
localField: 'product_id',
foreignField: '_id',
from: 'test-product',
as: 'proList',
})
.end()
这里foreignField字段用的_id,查不到数据
res = await db.collection('test-fav').aggregate()
.lookup({
localField: 'product_id',
foreignField: 'temp_id',
from: 'test-product',
as: 'proList',
})
.end()
foreignField字段用的temp_id,和_id值完全一样,查询就是正常的