Mongo

Joining collections in MongoDB

For the purposes of this article, I have created a collection called mongo2 and have furnished it with one of the records from the mongo collection, to ensure we get a join match. We can then run the below command: db.mongo.aggregate([ { $lookup: { from: “mongo2”, localField: “name”, foreignField: “name”, as: “new_join” } } ]).forEach(printjson) […]

Read more
Mongo

Simple Querying & Aggregation Of MongoDB Collections

Return all documents where one element in the array of likes is ‘burgers’ db.mongo.find({Likes : “burgers”}).forEach(printjson) Return documents where name includes, using Regex Here, we can use: FindOne() which returns the first document it finds Find() which returns all documents matching that criteria db.mongo.findOne({“name”:{$regex:”.*Kimi.*”}}) db.mongo.find({“name”:{$regex:”.*Kimi.*”}}) Return documents where field greater than X db.mongo.find({Age : {$gt:50}}).forEach(printjson) […]

Read more
Mongo

Introduction to MongoDB

MongoDB is a document oriented database and is one of the leaders of the NoSQL revolution. To summarize what a NoSQL database is, we can say that it’s a structure that enables us to consume data of varying structure (structured, semi-structured and unstructured), of varying schema and data type. They enable us to respond quickly […]

Read more