Anvi Jain has Published 500 Articles

Find data for specific date in MongoDB?

Anvi Jain

Anvi Jain

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

2K+ Views

Let’s say you have saved the Login date of users. Now, you want the count of records for specific date only i.e. login date. For this, use $gte and $lt operator along with count(). Let us first create a collection with documents −> db.findDataByDateDemo.insertOne({"UserName":"John", "UserLoginDate":new ISODate("2019-01-31")}); {    "acknowledged" : ... Read More

C function argument and return values

Anvi Jain

Anvi Jain

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

10K+ Views

Here we will see what are the different types of C functions based on the return values and arguments.So a function either can take some arguments, or nothing is taken. Similarly, a function can return something, otherwise does not return anything. So we can categorize them into four types.Function with ... Read More

How to read/retrieve data from Database to JSON using JDBC?

Anvi Jain

Anvi Jain

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

11K+ 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

MongoDB Limit fields and slice projection together?

Anvi Jain

Anvi Jain

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

286 Views

Use the $slice operator. Let us first create a collection with documents −> db.limitAndSliceProjectionDemo.insertOne(    {       "_id" : 101,       "UserName" : "Carol",       "UserAge" : 26,       "UserMesssage" : [          "Hi",          "Hello", ... Read More

Compiling multiple .cpp files in c++ program

Anvi Jain

Anvi Jain

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

2K+ Views

Here we will see how to compile multiple cpp file in C++ program. The task is very simple. We can provide the names as a list to the g++ compiler to compile them into one executable fileTo compile multiple files like abc.cpp, and xyz.cpp at once, the syntax will be ... Read More

Check input character is alphabet, digit or special character in C

Anvi Jain

Anvi Jain

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

3K+ Views

In this section, we will see how to check whether a given character is number, or the alphabet or some special character in C.The alphabets are from A – Z and a – z, Then the numbers are from 0 – 9. And all other characters are special characters. So ... Read More

How to insert an 8-byte integer into MongoDB through JavaScript shell?

Anvi Jain

Anvi Jain

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

261 Views

You can use below syntax for inserting an 8-byte integer in MongoDB through JavaScript shell −anyVariableName= {"yourFieldName" : new NumberLong("yourValue")};To display the above variable, you can use the variable name or printjson(). Following is the query to insert 8 byte integer in MongoDB −> userDetail = {"userId" : new NumberLong("98686869")}; ... Read More

How to change header background color of a table in Java

Anvi Jain

Anvi Jain

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

2K+ Views

To change header background color, at first get the header background −JTableHeader tableHeader = table.getTableHeader();Now, set the background color using set Background() −tableHeader.setBackground(Color.black);Above, we have used the Color class to set the color.The following is an example to change the header background color of a JTable −Examplepackage my; import java.awt.Color; ... Read More

How to get primary key value (auto-generated keys) from inserted queries using JDBC?

Anvi Jain

Anvi Jain

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

5K+ Views

If you insert records into a table which contains auto-incremented column, using a Statement or, PreparedStatement objects.You can retrieve the values of that particular column, generated by them object using the getGeneratedKeys() method.ExampleLet us create a table with name sales in MySQL database, with one of the columns as auto-incremented, using ... Read More

Simulating final class in C++

Anvi Jain

Anvi Jain

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

576 Views

In Java or C#, we can use final classes. The final classes are special type of class. We cannot extend that class to create another class. In C++ there are no such direct way. Here we will see how to simulate the final class in C++.Here we will create one ... Read More

Advertisements