22 lines
379 B
JavaScript
22 lines
379 B
JavaScript
|
export default defineEventHandler(async () => {
|
||
|
|
||
|
const storesColl = db.collection('stores');
|
||
|
|
||
|
const cursor = storesColl.aggregate([
|
||
|
{
|
||
|
$lookup:
|
||
|
{
|
||
|
from: "users",
|
||
|
localField: "ownerId",
|
||
|
foreignField: "_id",
|
||
|
as: "owner",
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
$unwind: "$owner",
|
||
|
},
|
||
|
])
|
||
|
|
||
|
return await cursor.toArray()
|
||
|
});
|