Hereâs my code pulling NTFs from the database, but âsortâ doesnât work, tried many things. Is there something wrong with my syntax?
// get user items
Moralis.Cloud.define('getUserItems', async (request) => {
const pipeline = [
{
match: {
contract_type: 'ERC721',
token_address: request.params.tokenAddress,
owner_of: { $in: request.params.forUserAddress ? request.params.forUserAddress : request.user.attributes.accounts },
},
},
{
lookup: {
from: 'ItemsForSale'+request.params.network,
localField: "token_id",
foreignField: "tokenId",
as: "marketItem"
}
},
{ sort : { createdAt: -1 } },
]
const query = new Moralis.Query(request.params.network+'NFTOwners')
return query.aggregate(pipeline)
},{
fields : ['network', 'tokenAddress'],
requireUser: true
})
Changing anything to sort, using other fields, nothing changes, always sorting the same.