const results = await Models.NFTs.aggregate([])
.lookup({
as: "creators.minter",
from: "users",
let: { minter: "$creators.minter", lazy_minter: "$lazy_mint_creator" },
pipeline: [
{
$match: {
$expr: {
$or: [
{ $in: ["$$minter", "$wallets"] },
{ $in: ["$$lazy_minter", "$wallets"] },
],
},
},
},
{
$project: { _id: 1, profile: 1, name: 1 },
},
],
})
.unwind("creators.minter")
.sort({ _id: -1 })
.project({
_id: 1,
nft_id: 1,
creators: 1,
editions: 1,
name: 1,
listing: 1,
url: 1,
})
the result:
"data":[
{
"_id":"62ba8e36cc78e90041e3829c",
"creators":{
},
"editions":{
},
"name":"fgfg",
"listing":{
},
"url":"link"
},
{
"_id":"62ba8e36cc78e90041e3829c",
"creators":{
},
"editions":{
},
"name":"fgfg",
"listing":{
},
"url":"link"
},
{
"_id":"62ba8e36cc78e90041e3829c",
"creators":{
},
"editions":{
},
"name":"fgfg",
"listing":{
},
"url":"link"
}
]