back then, there’s a web IDE where code can be pasted into but now everything has to be running on local IDE with moralis-admin-cli and I was wondering if there’s a way to deploy these functions? I keep getting "Invalid function: \"loadNFTs\"
and below is my code
Moralis.Cloud.define('loadNFTs', async (request) => {
const query = new Moralis.Query('NFT');
// TODO refactor nicely
if (request.params.hasOwnProperty('artistId')) {
query.equalTo('artistId', request.params.artistId);
}
if (request.params.hasOwnProperty('songId')) {
query.equalTo('songId', request.params.songId);
}
if (request.params.hasOwnProperty('rarity')) {
query.equalTo('rarity', request.params.rarity);
}
if (request.params.hasOwnProperty('featured')) {
query.equalTo('featured', request.params.featured);
}
if (request.params.hasOwnProperty('owner')) {
query.equalTo('owner', request.params.owner);
}
const nftMongoPipeline = [
{
group: {
objectId: {
displayName: '$displayName',
rarity: '$rarity',
description: '$description',
primarySalePrice: '$primarySalePrice',
},
total: {
$sum: 1,
},
available: {
$sum: {
$cond: {
if: {
$eq: ['$status', 'available'],
},
then: 1,
else: 0,
},
},
},
comingSoon: {
$sum: {
$cond: {
if: {
$eq: ['$status', 'comingSoon'],
},
then: 1,
else: 0,
},
},
},
displayName: { $first: '$displayName' },
rarity: { $first: '$rarity' },
description: { $first: '$description' },
primarySalePrice: { $first: '$primarySalePrice' },
imageURL: { $first: '$imageURL' },
songId: { $first: '$songId' },
artistId: { $first: '$artistId' },
mp3URL: { $first: '$mp3URL' },
},
},
{
project: {
objectId: 0,
},
},
];
const result = await query.aggregate(nftMongoPipeline);
return result;
});
any suggestions? what am I missing here?