Nishtha Thakur has Published 564 Articles

How to add a sub-document to sub-document array in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

Use the $push operator to add a sub-document. Let us first create a collection with documents −> db.subDocumentToSubDocumentDemo.insertOne(    {       "_id" :101,       "StudentName" : "Larry",       "StudentAge" : 21,       "StudentDetails" : [          {     ... Read More

How to declare a global variable in C++

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

To declare global variables in C++, we can declare variables after starting the program. Not inside any function or block. If we want to declare some variables that will be stored in some different file, then we can create one file, and store some variable. For some external file sometimes ... Read More

kbhit in C language

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

Here we will see the kbhit functionality in C. The kbhit is basically the Keyboard Hit. This function is present at conio.h header file. So for using this, we have to include this header file into our code.The functionality of kbhit() is that, when a key is pressed it returns ... Read More

Name Mangling and extern “C” in C++

Nishtha Thakur

Nishtha Thakur

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

881 Views

In C++ we can use the function overloading feature. Using this feature, we can create functions with same name. The only difference is the type of the arguments, and the number of arguments. The return type is not considered here. Now the question comes how the C++ distinguishes overloaded functions ... Read More

How to apply adjustments to the last column of a JTable only, when the width of any column is changed in Java Swing?

Nishtha Thakur

Nishtha Thakur

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

264 Views

To apply adjustments to the last column only, use the setAutoResizeMode and set the mode. The mode here would be AUTO_RESIZE_LAST_COLUMN. This will allow you to adjust only the last columns even if any of the column header is dragged to resize.Let us first see an example to create a ... Read More

How to retrieve auto-incremented value generated by Statement using JDBC?

Nishtha Thakur

Nishtha Thakur

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

204 Views

While creating a table, in certain scenarios, we need values to column such as ID, to be generated/incremented automatically. Various databases support this feature in different ways.In MySQL database you can declare a column auto increment using the following syntax.CREATE TABLE table_name(    ID INT PRIMARY KEY AUTO_INCREMENT,    column_name1 ... Read More

How to access subdocument value when the key is a number in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

108 Views

To access subdocument value, let us first create a collection with documents −> db.accessSubDocumentDemo.insertOne( ...    { ... ...       "Details" : { ...          "1" : { ...             "StudentLowerScore" : "33", ...             ... Read More

How to set the initial value of an auto-incremented column in MySQL using JDBC?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

While creating a table, in certain scenarios, we need values to column such as ID, to be generated/incremented automatically. Various databases support this feature in different ways.In MySQL database you can declare a column auto increment using the following syntax.CREATE TABLE table_name(    ID INT PRIMARY KEY AUTO_INCREMENT,    column_name1 ... Read More

Returning multiple values from a function using Tuple and Pair in C++

Nishtha Thakur

Nishtha Thakur

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

3K+ Views

In C or C++, we cannot return more than one value from a function. To return multiple values, we have to provide output parameter with the function. Here we will see another approach to return multiple value from a function using tuple and pair STL in C++.The Tuple is an ... Read More

Can MongoDB return result of increment?

Nishtha Thakur

Nishtha Thakur

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

98 Views

Yes, you can achieve this with findAndModify(). Let us first create a collection with documents −> db.returnResultOfIncementDemo.insertOne({"PlayerScore":98}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3c292edc6604c74817cda") }Following is the query to display all documents from a collection with the help of find() method −> db.returnResultOfIncementDemo.find();This will produce the following output ... Read More

Advertisements