Nishtha Thakur has Published 564 Articles

How to return only unique values (no duplicates) in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

866 Views

You can use distinct() to return only unique values. The syntax is as follows −db.yourCollectionName.distinct("yourFieldName");To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.returnOnlyUniqueValuesDemo.insertOne({"CusomerName":"Larry", "CustomerAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ed7262f684a30fbdfd580") ... Read More

Compare *ptr++, *++ptr and ++*ptr in C++

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

2K+ Views

In this section, we will see what are the differences between *ptr++, *++ptr and ++*ptr in C++.Here we will see the precedence of postfix++ and prefix++ in C or C++. The precedence of prefix ++ or -- has higher priority than dereference operator ‘*’ and postfix ++ or -- has ... Read More

How to use toLowerCase () in Android textview?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

1K+ Views

This example demonstrate about How to use toLowerCase () in Android textview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         ... Read More

Check that Field Exists with MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

169 Views

You can use the $exists and $ne operator for this. To understand the concept further, let us create a collection with document. The query to create a collection with document is as follows −> db.checkFieldExistDemo.insertOne({"EmployeeId":1, "EmployeeName":"John", "isMarried":true, "EmployeeSalary":4648585}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76f7b31e9c5dd6f1f78281") } > db.checkFieldExistDemo.insertOne({"StudentId":2, ... Read More

How to sum the value of a key across all documents in a MongoDB collection?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

4K+ Views

To get sum the value of a key across all documents in a MongoDB collection, you can use aggregate().To understand the above concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.sumOfValueDemo.insertOne({"Name":"Larry", "Amount":14.50}); {    "acknowledged" : ... Read More

C++ Program to Check if a Given Graph must Contain Hamiltonian Cycle or Not

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

225 Views

A Hamiltonian cycle is a Hamiltonian Path such that there is an edge (in graph) from the last vertex to the first vertex of the Hamiltonian Path. It is in an undirected graph is a path that visits each vertex of the graph exactly once.Functions and purposesBegin    1. function ... Read More

How do I display the indexes of a collection in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

270 Views

In order to display the indexes of a collection, you can use getIndexes(). The syntax is as follows −db.yourCollectionName.getIndexes();To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.indexDemo.insertOne({"StudentName":"Larry", "StudentAge":21}); {    "acknowledged" : true, ... Read More

Get distinct record values in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

365 Views

You can use distinct() method in MongoDB to get distinct record values. The syntax is as follows −db.yourCollectionName.distinct(“yourFieldName”);To understand the above syntax, let us create a collection with document. The query to create a collection with document is as follows −> db.distinctRecordDemo.insertOne({"StudentId":1, "StudentName":"John", "StudentAge":21}); {    "acknowledged" : true,   ... Read More

How to sort in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

124 Views

To sort in MongoDB, you can use the sort() method.Case 1 − Sort in ascending order. The syntax is as follows −db.yourCollectionName.find().sort({yourField:1});Case 2 − Sort in descending order. The syntax is as follows −db.yourCollectionName.find().sort({yourField:-1});To understand the concept, let us create a collection with the document. The query to create a ... Read More

References in C++

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

255 Views

A reference variable is an alias, that is, another name for an already existing variable. Once a reference is initialized with a variable, either the variable name or the reference name may be used to refer to the variable.References vs PointersReferences are often confused with pointers but three major differences ... Read More

Advertisements