Nishtha Thakur has Published 564 Articles

What is return type of db.collection.find() in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

The statement db.collection.find() returns the cursor of Result Set of a query by which you can iterate over the result set or print all documents.Let us first create a collection with documents −> db.findCursorDemo.insertOne({"ClientFirstName":"John", "ClientLastName":"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd00a1c588d4a6447b2e05c") } > db.findCursorDemo.insertOne({"ClientFirstName":"Carol", "ClientLastName":"Taylor"}); {   ... Read More

What's the best way to trim std::string in C++?

Nishtha Thakur

Nishtha Thakur

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

8K+ Views

Here we will see how to trim the strings in C++. The trimming string means removing whitespaces from left and right part of the string.To trim the C++ string, we will use the boost string library. In that library, there are two different methods called trim_left() and trim_right(). To trim ... Read More

How to create Android Notification with BroadcastReceiver?

Nishtha Thakur

Nishtha Thakur

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

4K+ Views

This example demonstrate about How to create Android Notification with BroadcastReceiver.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. Step 3 − Add the following ... Read More

MongoDB query to pull array element from a collection?

Nishtha Thakur

Nishtha Thakur

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

122 Views

Use the $pull operator to pull array element from a collection. Let us first create a collection with documents −> db.pullElementFromAnArrayDemo.insertOne( ...    { ...       "StudentScores":[89, 56, 78, 90] ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd0104a588d4a6447b2e063") }Following is the query ... Read More

How to highlight multiple rows in a sequence in a table with Java Swing?

Nishtha Thakur

Nishtha Thakur

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

171 Views

To highlight multiple rows 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

What is the effect of extern “C” in C++?

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

The extern “C” keyword is used to make a function name in C++ have the C linkage. In this case the compiler does not mangle the function. Let us see what is the mangling in C++ first, then we can discuss about the extern “C” keyword.In C++ we can use ... Read More

MongoDB equivalent of `select distinct(name) from collectionName where age = “25”`?

Nishtha Thakur

Nishtha Thakur

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

106 Views

You can use distinct() to get the equivalent of select distinct. Let us first create a collection with documents −> db.distinctNameAndAgeDemo.insertOne({"ClientFirstName":"John", "Age":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd12759e3526dbddbbfb60b") } > db.distinctNameAndAgeDemo.insertOne({"ClientFirstName":"Larry", "Age":25}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd12768e3526dbddbbfb60c") } > db.distinctNameAndAgeDemo.insertOne({"ClientFirstName":"David", "Age":25}); {   ... Read More

Java Program to remove the last row from a table with DefaultTableModel

Nishtha Thakur

Nishtha Thakur

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

483 Views

To remove the last row from a table, use the removeRow() method and set its parameter to total number of rows minus 1 since you need to remove the last row.Let us first see an example to display rows and columns in a JTable −Examplepackage my; import javax.swing.JFrame; import javax.swing.JScrollPane; ... Read More

Java program to get the previous sibling from a JTree

Nishtha Thakur

Nishtha Thakur

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

111 Views

Use the getPreviousSibling() method to get the previous sibling. Here, we are getting the previous sibling of child node “five” and displaying on Console −System.out.println("Get Previous Sibling = "+five.getPreviousSibling());The following is an example to get the previous sibling from a JTree −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public ... Read More

How do I convert between big-endian and little-endian values in C++?

Nishtha Thakur

Nishtha Thakur

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

6K+ Views

Here we will see how to convert Little endian value to Big endian or big endian value to little endian in C++. Before going to the actual discussion, we will see what is the big endian and the little endian?In different architectures, the multi-byte data can be stored in two ... Read More

Advertisements