/mongodbCRUD

Primary LanguageJavaScript

mongodbCRUD

This JavaScript code sets up a MongoDB client using the mongodb library and connects to a MongoDB cluster using the MongoClient constructor. It defines several functions to perform CRUD (Create, Read, Update, Delete) operations on a sample Airbnb dataset stored in a MongoDB database. The dotenv library is used to load environment variables, including the MongoDB cluster URI and password, from a .env file. The express library is used to create a basic web server. The main() function invokes the defined CRUD functions to perform database operations, including creating new listings, querying listings, and listing databases. Finally, the main() function closes the MongoDB client connection.