I am creating a sample nft market place.
here I hv a table for the collections called (FujiCollections).
I created the collections using.
const Collection = Moralis.Object.extend(âFujiCollectionsâ);
const collectionItem = new Collection({name:ânameâ,displayImage:âdisplayImageâ,symbol:âsymbolâ,description:âdescriptionâ,urlPath:âsample-url-pathâ,contractAddress:âcontractAddressâ,account:ââ});
collectionItem.save();
then I need to query the table FujiCollections from urlPath, for that I used,
const query = new Moralis.Query(Collection);
query.equalTo(âurlPathâ, âsample-url-pathâ);
const collectionResult = await query.first();
console.log(collectionResult);
this is working without a issue.
my concern is that when there are many entries in the FujiCollections table, this type of query will get slow.To get the result fast I hope to use the urlPath as a secondary index. So I can query faster.
what I try to achieve some think like above,When a user try to add a âshort urlâ , in my case urlPath,
I need to check the db quickly and find out a similar entry exits in the db.