Approach for Retrieve Data
1. Install requires dependencies like express for creating server and mongoose for connecting ,fetching and modification in database.
2. Connect to your mongodb database using mongoose.connect() method and provide your database URL.
3. Created dummy data and create mongoose shema like GFGSchema and inset data in database when mongoose.connect() method called.
4. Create a rote called “/” which helps to retrieve data form specified database using find() method which returns array of object.
Project Structure
How to Retrieve Data from MongoDB Using NodeJS?
MongoDB, the most popular NoSQL database, is an open-source document-oriented database. The term ‘NoSQL’ means ‘non-relational’. It means that MongoDB isn’t based on the table-like relational database structure but provides an altogether different mechanism for the storage and retrieval of data. This format of storage is called BSON ( similar to JSON format).