Anvi Jain has Published 629 Articles

MongoDB query for fields in embedded document?

Anvi Jain

Anvi Jain

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

175 Views

Let us first create a collection with documents −> db.embeddedDocumentDemo.insertOne( ...    { ...       "CustomerDetails":[ ...          {"CustomerName":"Chris", "CustomerPurchasePrice":3000}, ...          {"CustomerName":"Robert", "CustomerPurchasePrice":4500}, ...          {"CustomerName":"David", "CustomerPurchasePrice":1000}, ...       ] ...    } ... ); { ... Read More

How to push new items to an array inside of an object in MongoDB?

Anvi Jain

Anvi Jain

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

830 Views

You can use $elemMatch operator for this. Let us first create a collection with documents −> db.pushNewItemsDemo.insertOne(    {       "_id" :1,       "StudentScore" : 56,       "StudentOtherDetails" : [          {             "StudentName" : "John", ... Read More

sqrt, sqrtl and sqrtf in C++

Anvi Jain

Anvi Jain

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

746 Views

In the cmath library of C++, there are different functions for getting the square root except from sqrt. The sqrt is used basically for double type input. The others are used for float, long type data etc. Let us see the usage of these functions.The sqrt() FunctionThis function is used ... Read More

How to prevent resizing columns in a JTable

Anvi Jain

Anvi Jain

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

807 Views

To prevent resizing columns, use the method setResizingAllowed(). Here, we will set setResizingAllowed() to false for table header to disallow resizing of columns from header −table.getTableHeader().setResizingAllowed(false);Let us first see an example wherein we can easily resize columns in a table by resizing the table column header −Examplepackage my; import java.awt.Color; ... Read More

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

Enumerate over an enum in C++

Anvi Jain

Anvi Jain

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

307 Views

Enumeration is a user defined datatype in C/C++ language. It is used to assign names to the integral constants which makes a program easy to read and maintain. The keyword “enum” is used to declare an enumeration.The following is the syntax of enums.enum enum_name{const1, const2, ....... };Here, enum_name − Any ... Read More

C function argument and return values

Anvi Jain

Anvi Jain

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

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

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

208 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

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

Advertisements