How to find multiple mongo db objects at once in node js

Viewed 28

i am trying to run a search , it is working fine with findOne and recieving data but when i use find it just return some headers and prototypes like this

response i am getting

code

 let data = await client
.db("Movies")
.collection("movies")
.find();
console.log(data);

please tell me where i am going wrong

1 Answers

Based on documentation

The toArray() method returns an array that contains all the documents from a cursor. The method iterates completely the cursor, loading all the documents into RAM and exhausting the cursor.

so just try

 let data = await client
.db("Movies")
.collection("movies")
.find({}).toArray();
console.log(data);
Related