Nishtha Thakur has Published 564 Articles

Find all collections in MongoDB with specific field?

Nishtha Thakur

Nishtha Thakur

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

881 Views

Let us implement the above syntax in order to find all documents in MongoDB with field name “StudentFirstName”. The query is as follows −> db.getCollectionNames().forEach(function(myCollectionName) { ...    var frequency = db[myCollectionName].find({"StudentFirstName": {$exists: true}}).count(); ...    if (frequency > 0) { ...       print(myCollectionName); ...    } ... ... Read More

Implement MongoDB $concatArrays even when some of the values are null?

Nishtha Thakur

Nishtha Thakur

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

222 Views

Use aggregate framework along with $ifNull operator for this. The $concatArrays in aggregation is used to concatenate arrays. Let us first create a collection with documents −>db.concatenateArraysDemo.insertOne({"FirstSemesterSubjects": ["MongoDB", "MySQL", "Java"], "SecondSemesterSubjects":["C", "C++", ]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd687707924bb85b3f4895c") } > db.concatenateArraysDemo.insertOne({"FirstSemesterSubjects":["C#", "Ruby", "Python"]}); {    "acknowledged" ... Read More

C++ Program to Perform Searching Based on Locality of Reference

Nishtha Thakur

Nishtha Thakur

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

89 Views

Searching based on locality of reference, depends upon the memory access pattern data elements are reallocated.Here linear searching method is used to search an element.AlgorithmBegin    int find(int *intarray, int n, int item)    intialize comparisons = 0    for i = 0 to n-1       Increase comparisons ... Read More

Print a number 100 times without using loop, recursion and macro expansion in C

Nishtha Thakur

Nishtha Thakur

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

400 Views

In this section we will see how to print a number 100 times in C. There are some constraints. We cannot use loops, recursions or macro expansions.To solve this problem we will use the setjump and longjump in C. The setjump() and longjump() is located at setjmp.h library. The syntax ... Read More

How to concatenate results in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

239 Views

You can concatenate results with the help of forEach(). Let us first create a collection with documents −> db.concatenateDemo.insertOne({"Name":"John", "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc80dd88f9e6ff3eb0ce448") } > db.concatenateDemo.insertOne({"Name":"Carol", "Age":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc80de18f9e6ff3eb0ce449") }Following is the query to display all documents ... Read More

How to customize how a JTabbedPane looks in Java?

Nishtha Thakur

Nishtha Thakur

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

631 Views

To customize how a JTabbedPane looks, change its font style, font face, font size and the background and foreground colors.Let’s say the following is the JTabbedPane −JTabbedPane tabbedPane = new JTabbedPane();Now, let us customize the above created JTabbedPane −tabbedPane.setBackground(Color.orange); tabbedPane.setForeground(Color.white); Font font = new Font("Verdana", Font.CENTER_BASELINE, 18); tabbedPane.setFont(font);The following is ... Read More

Display MongoDB records by ObjectId?

Nishtha Thakur

Nishtha Thakur

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

81 Views

Let us first create a collection with documents −> db.findByObjectIdDemo.insertOne({"ClientName":"Larry", "ClientAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd68cd657806ebf1256f11a") } > db.findByObjectIdDemo.insertOne({"ClientName":"Chris", "ClientAge":26}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd68cdc57806ebf1256f11b") } > db.findByObjectIdDemo.insertOne({"ClientName":"David", "ClientAge":38, "isMarried":true}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd68cf657806ebf1256f11c") }Following is the ... Read More

How to group android notifications like whatsapp?

Nishtha Thakur

Nishtha Thakur

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

671 Views

This example demonstrate about How to group android notifications like whatsappStep 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 − ... Read More

Update object at specific Array Index in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

517 Views

To update object at specific array index, use update() in MongoDB. Let us first create a collection with documents −> db.updateObjectDemo.insertOne( ...   { ...       id : 101, ...       "StudentDetails": ...       [ ...          [ ...     ... Read More

How to set Line Border color and width with Java?

Nishtha Thakur

Nishtha Thakur

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

4K+ Views

To set Line Border color and width, use the LineBorder. At first, set a panel wherein we need to set the line border −JPanel panel = new JPanel();Now, create a border and set on the panel created above −Border border = new LineBorder(Color.ORANGE, 4, true); panel.setBorder(border);The following is an example ... Read More

Advertisements