Found 1659 Articles for Big Data Analytics

MongoDB aggregate to get the Mean daily average count of recorded documents in a collection?

AmitDiwan
Updated on 11-May-2020 10:07:14

743 Views

To get the mean daily average count of recorded documents, use aggregate(). Within that, use $project and $group.Let us create a collection with documents −Example> db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-15T10:50:35.000Z"), ... Value: 10 ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6e9") } > db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-14T10:50:35.000Z"), ... Value: 10 ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6ea") } > db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-13T10:50:35.000Z"), ... Value: 10 ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6eb") }Display all documents from a collection with the help of find() ... Read More

How to reach subdata in MongoDB and display a particular document?

AmitDiwan
Updated on 11-May-2020 09:02:59

115 Views

In order to reach subdata, you need to use key in MongoDB. Let us create a collection with documents −>db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"Chris", "StudentAge":21}}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7b590e71f552a0ebb0a6e6") } >db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"David", "StudentAge":23}}});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b591a71f552a0ebb0a6e7") } >db.demo450.insertOne({"Information":{"StudentDetails":{"StudentName":"Mike", "StudentAge":22}}});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7b592271f552a0ebb0a6e8") }Display all documents from a collection with the help of find() method −> db.demo450.find();This will produce the following output −{ "_id" : ObjectId("5e7b590e71f552a0ebb0a6e6"), "Information" : { "StudentDetails" : { "StudentName" : "Chris", "StudentAge" : 21 } } } { "_id" : ObjectId("5e7b591a71f552a0ebb0a6e7"), "Information" : { "StudentDetails" : { ... Read More

How to insert an item to an array that is inside an object in MongoDB?

AmitDiwan
Updated on 11-May-2020 09:02:05

762 Views

To insert an item to an already created array inside an object, use MongoDB $push. Let us create a collection with documents −> db.demo449.insertOne( ... { ...    details1: { ...       details2: [{ ...          _id:new ObjectId(), ...             Name:"Chris" ...       }], ...       details3: [{ ...          _id:new ObjectId(), ...          Name:"David" ...       }] ...    } ... } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e7a40e971f552a0ebb0a6e3") }Display all documents from ... Read More

What is the difference between deleteOne() and findOneAndDelete() operation in MongoDB?

AmitDiwan
Updated on 11-May-2020 08:59:12

2K+ Views

The findOneAndDelete() deletes single documents from the collection on the basis of a filter and sort criteria as well as it returns the deleted document.The deleteOne() removes single document from the collection.Let us see an example and create a collection with documents −> db.demo448.insertOne({"Name":"Chris", "Age":21});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7a291cbbc41e36cc3caeca") } > db.demo448.insertOne({"Name":"David", "Age":23});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7a2926bbc41e36cc3caecb") } > db.demo448.insertOne({"Name":"Bob", "Age":22});{    "acknowledged" : true,    "insertedId" : ObjectId("5e7a2930bbc41e36cc3caecc") }Display all documents from a collection with the help of find() method −> db.demo448.find();This will produce the following output −{ "_id" : ObjectId("5e7a291cbbc41e36cc3caeca"), ... Read More

Difference between Data Scientist, Data Engineer, Data Analyst

Kiran Kumar Panigrahi
Updated on 11-Jan-2023 14:46:13

631 Views

Data scientists, data engineers, and data analysts are all professionals who work with data in some way. However, they have different roles and responsibilities. Read this article to find out more the job profiles of data scientists, data engineers, and data analysts and how you can distinguish among them. Who is a Data Scientist? A Data Scientist is one who analyses and interprets complex data in digital form. Data scientists are responsible for extracting insights and knowledge from data. They use a variety of techniques, including machine learning, to analyze data and communicate their findings to stakeholders. There are several ... Read More

How to aggregate two collections where a field from one collection is greater than the other in MongoDB?

AmitDiwan
Updated on 06-Apr-2020 13:40:32

434 Views

For this, you can use $lookup. Let us create a collection with documents −> db.demo446.insert([ ...    { "ProductName": "Product1", "ProductPrice": 60 }, ...    { "ProductName": "Product2", "ProductPrice": 90 } ... ]) BulkWriteResult({    "writeErrors" : [ ],    "writeConcernErrors" : [ ],    "nInserted" : 2,    "nUpserted" : 0,    "nMatched" : 0,    "nModified" : 0,    "nRemoved" : 0,    "upserted" : [ ] })Display all documents from a collection with the help of find() method −> db.demo446.find();This will produce the following output −{ "_id" : ObjectId("5e790766bbc41e36cc3caec3"), "ProductName" : "Product1", "ProductPrice" : 60 } { ... Read More

Cannot push into an array from MongoDB?

AmitDiwan
Updated on 06-Apr-2020 13:36:21

118 Views

To push into an array with MongoDB, use $push. Let us create a collection with documents −> db.demo445.insertOne({"ListOfFriends":["Robert", "Mike", "Sam", "Carol", "David", "Mike"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e78f099bbc41e36cc3caec2") }Display all documents from a collection with the help of find() method −> db.demo445.find().pretty();This will produce the following output −{    "_id" : ObjectId("5e78f099bbc41e36cc3caec2"),    "ListOfFriends" : [       "Robert",       "Mike",       "Sam",       "Carol",       "David",       "Mike"    ] }Following is the query to push into an array −> db.demo445.update( ...    { ... Read More

How to improve MongoDB queries with multikey index in array?

AmitDiwan
Updated on 06-Apr-2020 13:32:46

124 Views

For this, use $elemMatch, which is used to query nested objects. Let us create a collection with documents −> db.demo444.insertOne( ...    { ...       "Information": [{ ...          id:1, ...          Name:"Chris" ...       }] ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e78ea87bbc41e36cc3caebf") } > db.demo444.insertOne( ...    { ...       "Information": [{ ...          id:2, ...          Name:"David" ...       }] ...    } ... ); {    "acknowledged" : true,   ... Read More

MongoDB profiler output: What is the “command” operation?

AmitDiwan
Updated on 06-Apr-2020 13:30:22

172 Views

The following operations are treated as command operation in MongoDB −1.count 2.findAndModify 3.aggregateFollowing is the example of count in MongoDB −Let us create a collection with documents −> db.demo443.insertOne({"Name":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e78d281bbc41e36cc3caeb9") } > db.demo443.insertOne({"Name":"Bob"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e78d285bbc41e36cc3caeba") } > db.demo443.insertOne({"Name":"David"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e78d288bbc41e36cc3caebb") }Display all documents from a collection with the help of find() method −> db.demo443.find();This will produce the following output −{ "_id" : ObjectId("5e78d281bbc41e36cc3caeb9"), "Name" : "Chris" } { "_id" : ObjectId("5e78d285bbc41e36cc3caeba"), "Name" : "Bob" } { "_id" : ... Read More

Getting distinct values from object array in MongoDB?

AmitDiwan
Updated on 06-Apr-2020 13:28:05

1K+ Views

To get distinct values from object array in MongoDB, use distinct(). Let us create a collection with documents −> db.demo442.insertOne( ...    { ... ...       "Information" : [ ...          { ...             "FirstName" : "John", ...             "Age" : 21 ...          }, ...          { ...             "FirstName" : "Sam", ...             "Age" : 23 ...          }, ...         ... Read More

Advertisements