Skip to content

Mandeepmat/Node-MongoDB-Query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Node-MongoDB-Query

Creating a query in MongoDB node.js

When finding documents in a collection, you can filter the result by using a query object.

The first argument of the find() method is a query object, and is used to limit the search.

var MongoClient = require('mongodb').MongoClient; var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) { if (err) throw err; var dbo = db.db("mydb"); var query = { address: "Park Lane 38" }; dbo.collection("customers").find(query).toArray(function(err, result) { if (err) throw err; console.log(result); db.close(); }); });

About

Creating a query in MongoDB node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published