Nishtha Thakur has Published 564 Articles

How to filter array elements in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

253 Views

You can use $setIntersection operator along with aggregate framework to filter array elements in MongoDB. Let us first create a collection with documents −> db.filterArrayElementsDemo.insertOne( { "Scores": [10, 45, 67, 78, 90, 98, 99, 92] } ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2d582b64f4b851c3a13c8") }Following is the query ... Read More

Check whether field exist in MongoDB or not?

Nishtha Thakur

Nishtha Thakur

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

164 Views

You can use $exists operator for this. Let us first create a collection with documents −>db.checkFieldExistsDemo.insertOne({"StudentFirstName":"John", "StudentGender":"Male", "StudentMongoDBScore":89}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd909611a844af18acdffbd") } >db.checkFieldExistsDemo.insertOne({"StudentFirstName":"Emma", "StudentGender":"Female", "StudentMongoDBScore":58}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd909781a844af18acdffbe") } >db.checkFieldExistsDemo.insertOne({"StudentFirstName":"Carol", "StudentGender":"Male", "StudentMongoDBScore":77}); {    "acknowledged" : true,   ... Read More

How to ceate right justified JTextField in Java?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

To create right justified JTextField, set the alignment to be RIGHT. Here, we will be using the setHorizontalAlignment() method as well and within that the alignment would be set.Create a JTextField −JTextField emailId = new JTextField(20);Now, align it to the right −emailId.setHorizontalAlignment(JTextField.RIGHT);The following is an example to create right justified ... Read More

nextafter() and nexttoward() in C/C++

Nishtha Thakur

Nishtha Thakur

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

177 Views

Here we will see the effect of nextafter() and nextforward() functions in C or C++. These functions are present in the math.h or cmath library.if the functions are like nextafter(a, b) and nextforward(a, b). These functions are used to find the next representable value after a in the direction of ... Read More

Get at least one match in list querying with MongoDB?

Nishtha Thakur

Nishtha Thakur

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

363 Views

Use $in operator to get at least one match. Let us first create a collection with documents −> db.atleastOneMatchDemo.insertOne({"StudentFavouriteSubject":["MySQL", "MongoDB"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2db5db64f4b851c3a13ce") } > db.atleastOneMatchDemo.insertOne({"StudentFavouriteSubject":["Java", "C", "MongoDB"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2db71b64f4b851c3a13cf") } > db.atleastOneMatchDemo.insertOne({"StudentFavouriteSubject":["Python", "C++", "SQL Server"]}); { ... Read More

How do I search according to fields in inner classes using MongoDB db.coll.find()?

Nishtha Thakur

Nishtha Thakur

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

103 Views

Use dot notation(.) to search in inner classes using MongoDB. Let us first create a collection with documents −> db.searchInInnerDemo.insertOne( ...    { ...       "StudentFirstName" : "Robert", ...       "StudentTechnicalDetails": ...       { ...          "StudentBackEndTechnology" : "MongoDB", ...   ... Read More

Get all fields names in a MongoDB collection?

Nishtha Thakur

Nishtha Thakur

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

3K+ Views

You can use the concept of Map Reduce. Let us first create a collection with documents −> db.getAllFieldNamesDemo.insertOne({"StudentFirstName":"David", "StudentAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd998e9b50a6c6dd317ad90") }Following is the query to display all documents from a collection with the help of find() method −> db.getAllFieldNamesDemo.find();This will produce the ... Read More

Java Program to enable drag and drop between two text fields in Java

Nishtha Thakur

Nishtha Thakur

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

356 Views

Yes, we can enable drag and drop between two text fields in Java. Let us first create two JTextFields and set content in it as shown below −JTextField one = new JTextField(20); one.setText("You can drag!"); JTextField two = new JTextField(20); two.setText("Drag here or there");Now, we will enable and drag and ... Read More

pthread_self() in C

Nishtha Thakur

Nishtha Thakur

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

7K+ Views

Here we will see what will be the effect of pthread_self() in C. The pthread_self() function is used to get the ID of the current thread. This function can uniquely identify the existing threads. But if there are multiple threads, and one thread is completed, then that id can be ... Read More

How to determine if an activity has been called by a Notification in Android?

Nishtha Thakur

Nishtha Thakur

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

299 Views

This example demonstrate about How to determine if an activity has been called by a Notification in AndroidStep 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 ... Read More

Advertisements