Smita Kapse has Published 498 Articles

How to get array from a MongoDB collection?

Smita Kapse

Smita Kapse

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

365 Views

You can use aggregate framework. Let us first create a collection with documents −> db.getArrayDemo.insertOne(    {       "CustomerId":101,       "CustomerDetails":[          {             "CustomerName":"Larry",             "CustomerFriendDetails":[             ... Read More

Why strict aliasing is required in C?

Smita Kapse

Smita Kapse

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

206 Views

Here we will see, why we should use the strict aliasing in C. Before discussing that part, let us see one code, and try to analyze the output.Example#include int temp = 5; int* var = &temp; int my_function(double* var) {    temp = 1;    *var = 5.10; //this will change the value of temp    return (temp); } main() {    printf("%d",  my_function((double*)&temp)); }Output1717986918If we ... Read More

How to make an icon in the action bar with the number of notifications in Android?

Smita Kapse

Smita Kapse

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

208 Views

This example demonstrate about How to make an icon in the action bar with the number of notifications 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 ... Read More

Updating sub-object in MongoDB?

Smita Kapse

Smita Kapse

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

496 Views

You can use $set operator for this. Let us first create a collection with documents −> db.updateSubObjectDemo.insertOne( ...    { ... ...       "ClientId" : 100, ...       "ClientDetails" : { ...          "ClientFirstName" : "Adam" ...       } ...   ... Read More

Push new key element into subdocument of MongoDB?

Smita Kapse

Smita Kapse

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

302 Views

You can use $set operator for this. Following is the syntax −db.yourCollectionName.update({"_id" : yourObjectId }, {$set: { "yourOuterFieldName.anyInnerFieldName": yourValue}});Let us first create a collection with documents −> db.pushNewKeyDemo.insertOne({"UserId":100, "UserDetails":{}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cda58f5b50a6c6dd317adbf") }Following is the query to display all documents from a collection with ... Read More

remainder() in C++

Smita Kapse

Smita Kapse

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

205 Views

Here we will see the functionality of remainder() method of C++. The remainder() function is used to compute the floating point remainder of numerator/denominator.So the remainder(x, y) will be like below.remainder(x, y) = x – rquote * yThe rquote is the value of x/y. This is rounded towards the nearest ... Read More

What does it mean when a numeric constant in C/C++ is prefixed with a 0?

Smita Kapse

Smita Kapse

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

185 Views

Sometimes we may see some numeric literals, which is prefixed with 0. This indicates that the number is octal number. So octal literals contain 0 at the beginning. For example, if an octal number is 25, then we have to write 025.Example#include int main() {    int a = ... Read More

Java program to lay out components in a flow to be centered with FlowLayout?

Smita Kapse

Smita Kapse

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

203 Views

Use FlowLayout.CENTER to lay out components in a flow to be centered with FlowLayout. The following is an example to lay out components in a flow to be centered with FlowLayout −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public ... Read More

How to select where sum of fields is greater than a value in MongoDB?

Smita Kapse

Smita Kapse

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

321 Views

You can use $where operator for this. Let us first create a collection with documents −> db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":10, "Price2":50, "Price3":40}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd84b8bf3115999ed511e6") } > db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":11, "Price2":1, "Price3":120}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd84c6bf3115999ed511e7") } > db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":10, "Price2":9, "Price3":6}); {    "acknowledged" ... Read More

How to create a collection correctly in MongoDB to avoid “ReferenceError: Not defined” error?

Smita Kapse

Smita Kapse

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

2K+ Views

To create a collection correctly you need to use a MongoDB object in call i.e.db.createCollection("yourCollectionName");Let us implement the above syntax in order to create a collection and call it using a MongoDB object −> use sample; switched to db sample > db.createCollection("employeeInformation"); { "ok" : 1 }Display all the ... Read More

Advertisements