Nishtha Thakur has Published 564 Articles

Project specific array field in a MongoDB collection?

Nishtha Thakur

Nishtha Thakur

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

179 Views

Let us first create a collection with documents −> db.projectionAnElementDemo.insertOne( ...    { ...       "CustomerId":100, ...       "CustomerDetails": [ ...          { ...             "CustomerName": "Chris", ...             "CustomerCountryName": "US" ...   ... Read More

How to update multiple documents in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

328 Views

You need to use multi:true to update multiple documents. Let us first create a collection with documents −> db.multiUpdateDemo.insertOne({"ClientName":"John", "ClientAge":29}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cda5bc0b50a6c6dd317adc8") } > db.multiUpdateDemo.insertOne({"ClientName":"Carol", "ClientAge":31}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cda5bc1b50a6c6dd317adc9") } > db.multiUpdateDemo.insertOne({"ClientName":"John", "ClientAge":39}); {    "acknowledged" : ... Read More

abs(), labs(), llabs() functions in C/C++

Nishtha Thakur

Nishtha Thakur

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

118 Views

In the cstdlib library of C++, there are different functions for getting the absolute value except from abs. The abs are used basically for int type input in C, and int, long, long long in C++. The others are used for long, and long long type data etc. Let us ... Read More

How to prevent class inheritance in C++

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

Here we will see how to prevent inheritance in C++. The concept of preventing the inheritance is known as final class.In Java or C#, we can use final classes. In C++ there are no such direct way. Here we will see how to simulate the final class in C++.Here we ... Read More

How to highlight a row in a table with Java Swing?

Nishtha Thakur

Nishtha Thakur

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

941 Views

To highlight a row in a table, you can use the addRowSelectionInterval() method. At first create a table −DefaultTableModel tableModel = new DefaultTableModel(); JTable table = new JTable(tableModel);Add some columns −tableModel.addColumn("Language/ Technology"); tableModel.addColumn("Text Tutorial"); tableModel.addColumn("Video Tutorial"); tableModel.addColumn("Views");Now, add rows to the table −tableModel.addRow(new Object[] { "NodeJS", "No", "Yes", "2350"}); tableModel.addRow(new ... Read More

Efficient way to remove all entries from MongoDB?

Nishtha Thakur

Nishtha Thakur

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

183 Views

If you will try to use the method drop(), then it will delete all information about the collection. Indexing is fast. However, if you will use the method remove(), then it removes all records but keeps the collection and indexes.Let us check with the help of example.Using drop()Let us first ... Read More

What is difference between GCC and G++ Compilers?

Nishtha Thakur

Nishtha Thakur

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

595 Views

We use gcc and g++ compilers in different times. Here we will see what are the differences between gcc and g++.The gcc is GNU C compiler, and g++ is GNU C++ compiler. The main differences are like below −gcc can compile *.c or *.cpp files as C and C++ respectivelyg++ ... Read More

Conditional $first in MongoDB aggregation ignoring NULL?

Nishtha Thakur

Nishtha Thakur

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

408 Views

You can use $match operator under aggregate() to get the first record. Let us first create a collection with documents −> db.conditionalFirstDemo.insertOne({_id:100, "StudentName":"Chris", "StudentSubject":null}); { "acknowledged" : true, "insertedId" : 100 } > db.conditionalFirstDemo.insertOne({_id:101, "StudentName":"Chris", "StudentSubject":null}); { "acknowledged" : true, "insertedId" : 101 } >db.conditionalFirstDemo.insertOne({_id:102, "StudentName":"Chris", "StudentSubject":"MongoDB"}); { "acknowledged" : ... Read More

How to insert/store JSON array into a database using JDBC?

Nishtha Thakur

Nishtha Thakur

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

9K+ Views

A Json array is an ordered collection of values that are enclosed in square brackets i.e. it begins with ‘[’ and ends with ‘]’. The values in the arrays are separated by ‘, ’ (comma).Sample JSON array{    "books": [ Java, JavaFX, Hbase, Cassandra, WebGL, JOGL] }The json-simple is a ... Read More

Middle of three using minimum comparisons in C++

Nishtha Thakur

Nishtha Thakur

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

463 Views

In this section, we will see how to find the middle of three given values by comparing them. So if three numbers are given like (10, 30, 20), then it will find 20 as this is the middle element. Let us see the algorithm first, then we will implement that ... Read More

Advertisements