How to migrate Moralis.Query from v1 to MongoDB

How to simply replace this code form the “Rarity Ranking App example” which is in Moralis v1 to a MongoDB query using their free tier.

Code excerpt:
const dbNFTs = Moralis.Object.extend(col);
const query = new Moralis.Query(dbNFTs);

Here the link to the example github:

Thanks for any support in advance !

Hello, can you give more context about what you mean with migrating to MongoDB?

where from you want to make the queries? (front end, backend, what stack/programming language)

The “Rarity Ranking App example” is using Moralis v1 and is a frontend app (see github link).
This example is a fork of Ethereum Boilerplate and demonstrates how you can build your own NFT Rarity Ranker.
But the app is basically only using the discontinued backend database of Moralis v1.

Now I want to replace the SKD calls like the two listed in the post with calls to MongoDB (the free cloud tier), so I can keep the code as untouched as possible (even without Moralis v1).

Hope this helps to clarify a bit :wink:

If you are planning to do mongo db queries in front end you will need a backend component to handle the connection to mongo db as you probably don’t want to hardcode mongo db credentials in front end.

Other than that you should’ve able to use a library/sdk specific to mongo db for making the queries.

Ok. Thanks for the feedback !