Srajal Dwivedi
Srajal Dwivedi

Reputation: 36

The QuickStart Guide documentation mongoDB code returns null

const { MongoClient } = require("mongodb");
// Replace the uri string with your connection string.
const uri = "<your URI string>";

const client = new MongoClient(uri);
async function run() {
  try {
    const database = client.db('sample_mflix');
    const movies = database.collection('movies');
    // Query for a movie that has the title 'Back to the Future'
    const query = { title: 'Back to the Future' };
    const movie = await movies.findOne(query);
    console.log(movie);
  } finally {
    // Ensures that the client will close when you finish/error
    await client.close();
  }
}
run().catch(console.dir);

This is the code from mongoDB quickStart Documentation I did all the steps correctly and also did everything right did put the correct uri string too but it returns null for the query , which is not according to the mongoDB quickStart Guide

Upvotes: 0

Views: 21

Answers (0)

Related Questions