Nishtha Thakur has Published 387 Articles

How do I check whether a field contains null value in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

379 Views

You can use $type operator to check whether a filed contains null value. Let us first create a collection with documents. We have also inserted a null in a field −> db.nullDemo.insertOne({"FirstName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc68a1eac184d684e3fa270") } > db.nullDemo.insertOne({"FirstName":null}); {    "acknowledged" : true,   ... Read More

Distribute extra horizontal and vertical space in a GridBagLayout with Java

Nishtha Thakur

Nishtha Thakur

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

881 Views

To distribute the extra horizontal and vertical space, use the fields weightx and weighty. The following is an example to distribute extra horizontal and vertical space −Examplepackage my; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo {    public static void ... Read More

How to change the output of printf() in main()?

Nishtha Thakur

Nishtha Thakur

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

362 Views

Here we will see how to change the output of the printf() function from main(). Here we will define a function that will change all of the printf() statements with the given type to another type.We will use the #define macro to do this task. This macro will be defined ... Read More

How to maintain the top count of array elements in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

161 Views

You can use aggregate framework. Let us first create a collection with documents −> db.topCountArrayDemo.insertOne( ...    {"StudentId":101 , "StudentSubject": ["C", "MongoDB"]} ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6b3209cb58ca2b005e669") } > db.topCountArrayDemo.insertOne( ...    {"StudentId":102 , "StudentSubject": ["C", "Java"]} ... ); {    "acknowledged" : true, ... Read More

Set a component and place it next to the previously added component with GridBagLayout in Java

Nishtha Thakur

Nishtha Thakur

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

200 Views

We have set a component first −GridBagConstraints constraints = new GridBagConstraints(); constraints.gridy = 0; panel.add(new JButton("First row"), constraints);Now, we will place it next to the previously added component −constraints.gridx = GridBagConstraints.RELATIVE; constraints.gridy = 1; panel.add(new JButton("2nd row 1st column"), constraints); panel.add(new JButton("2nd row 2nd column"), constraints);Examplepackage my; import java.awt.GridBagConstraints; import ... Read More

C program that won’t compile in C++

Nishtha Thakur

Nishtha Thakur

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

553 Views

The C++ language is designed by adding some additional features like Object Oriented concepts with C. Most of the C programs can be compiled using C++ compiler also. Though there are some programs that cannot be compiled using C++ compiler.Let us see some code, that will compile in C compiler, ... Read More

How to remove key fields in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

To remove key fields in MongoFB, you can use $unset operator. Let us first create a collection with documents −>db.removeKeyFieldsDemo.insertOne({"StudentFirstName":"John", "StudentLastName":"Doe", "StudentAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6c8289cb58ca2b005e672") } >db.removeKeyFieldsDemo.insertOne({"StudentFirstName":"John", "StudentLastName":"Smith", "StudentAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6c8359cb58ca2b005e673") }Following is the query to display ... Read More

trunc() , truncf() , truncl() in C language

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

Here we will see three functions. These functions are trunc(), truncf() and the truncl(). These functions are used to convert floating point values into truncated form.The trunc() FunctionThis function is used to truncate double type value. And return only the integer part. The syntax is like below.double trunc(double argument)Example#include ... Read More

Variable collection name in MongoDB shell with JavaScript?

Nishtha Thakur

Nishtha Thakur

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

272 Views

Yes, you can set a variable collection name in MongoDB shell using JavaScript. Let us first create a collection with documents −> db.employeeInformation.insertOne({"EmployeeName":"John Smith", "EmployeeAge":24, "EmployeeSalary":450000}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc6d06baf8e7a4ca6b2ad97") }Following is the query to display all documents from a collection with the help of ... Read More

How do you perform an AND query on an array in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

233 Views

To get the same result like AND in MongoDB, use the $all operator. Let us first create a collection with documents −> db.andQueryDemo.insertOne({"StudentName":"Carol Taylor", "FavouriteSubject":["C", "Java", "MongoDB", "MySQL"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc73e7a8f9e6ff3eb0ce433") } > db.andQueryDemo.insertOne({"StudentName":"David Miller", "FavouriteSubject":["C++", "Java", "MongoDB", "SQL Server"]}); {    "acknowledged" : ... Read More

Previous 1 ... 7 8 9 10 11 ... 39 Next
Advertisements