I have multiple queries which all have a shared id.
I am trying to join these queries into a single output but can not seem to figure it out.
Any ideas? Thank you!
Collection contains customers and sellers (id of each, date of sale, etc.). The intended output is one that contains (seller id, buyer id, number of time seller has sold an item, number of distinct customer seller has sold to, array of distinct customers seller has sold to, array of transaction id).
I've been able to query each component, for example:
Array of seller ids seller has sold to
db.completedSessions.aggregate([
{
$group:
{
_id: {seller: "$sellerId"}, customer_id_array: {$push: "$customerId"}
}
}
])
Count of sales by seller
db.completedSessions.aggregate([
{
$group:
{
_id: {user: "$sellerId"}, count: {$sum: 1}
}
}
])
I'm trying to join these queries together using the sellerId.