Skip to content

Commit 1108a55

Browse files
committed
Using thw find and cursor
1 parent fd95cbc commit 1108a55

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

mongodb.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,11 @@ MongoClient.connect(connectionURL,{useNewUrlParser:true, useUnifiedTopology: tru
1616
//The database that we are trying to maniplulate
1717
const db = client.db(databaseName);
1818

19-
db.collection('users').insertOne(
20-
{
21-
_id: id,
22-
name: "Sarthak",
23-
age: 17,
24-
},
25-
(err, result)=>{
19+
db.collection('tasks').find({completed:true}).toArray((err, array)=>{
2620
if (err) {
27-
return console.log("Unable to insert");
21+
return console.log(err);
2822
}
2923

30-
console.log(result.ops);
24+
console.log(array);
3125
});
3226
});

0 commit comments

Comments
 (0)