Smita Kapse has Published 498 Articles

“Toggle” query in MongoDB?

Smita Kapse

Smita Kapse

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

413 Views

You need to find the document and after that you need to use update to toggle query. Let us first create a collection with documents −> db.toggleDemo.insertOne({"CustomerName":"John Smith", "CustomerAge":28, "isMarried":true}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc7be138f9e6ff3eb0ce43b") } > db.toggleDemo.insertOne({"CustomerName":"David Miller", "CustomerAge":25, "isMarried":false}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc7be2e8f9e6ff3eb0ce43c") }Following is the query to display ... Read More

How to remove white spaces (leading and trailing) from string value in MongoDB?

Smita Kapse

Smita Kapse

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

633 Views

For this, you need to write some code using forEach(). Let us first create a collection with documents −> db.removingWhiteSpaceDemo.insertOne({"Title":" Introduction to java "}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd66f387924bb85b3f4894c") }Following is the query to display all documents from a collection with the help of find() method ... Read More

Pull multiple objects from an array in MongoDB?

Smita Kapse

Smita Kapse

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

1K+ Views

To pull multiple objects from an array, you can use $pull operator. Let us first create a collection with documents −> db.pullMultipleObjectsDemo.insertOne( ...    { ...       "ClientId" : "100", ...       "ClientName" : "John", ...       "ClientPersonalDetails" : [ ...       ... Read More

MongoDB query check if value in array property?

Smita Kapse

Smita Kapse

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

2K+ Views

You can use $in operator to check if a value is in an array or not. Let us first create a collection with documents −> db.valueInArrayDemo.insertOne({"UserName":"John", "UserMessage":["Hi", "Hello", "Bye"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd684cf7924bb85b3f48959") } > db.valueInArrayDemo.insertOne({"UserName":"Larry", "UserMessage":["Thank You", "Amazing", "Nice"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd684d27924bb85b3f4895a") } >db.valueInArrayDemo.insertOne({"UserName":"Carol", "UserMessage":["Awesome", "Bye", "Cool"]}); { ... Read More

Bind function and placeholders in C++

Smita Kapse

Smita Kapse

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

2K+ Views

Here we will see the Bind function and the placeholders in C++. Sometimes we need to manipulate the operation of some functions as we need. We can use some default parameters to get some essence of manipulating.In C++11, one new feature is introduced, called the bind function. This helps us ... Read More

Program to display hostname and IP address C

Smita Kapse

Smita Kapse

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

549 Views

In this section we will see how to see the Host name and IP address of the local system in an easier way. We will write a C program to find the host name and IP.Some of the following functions are used. These functions have a different task. Let us ... Read More

Remove and update the existing record in MongoDB?

Smita Kapse

Smita Kapse

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

146 Views

You can use only $pull operator that removes and updates the existing record in MongoDB. Let us first create a collection with documents −> db.removeDemo.insertOne( ...    { ...       "UserName" : "Larry", ...       "UserDetails" : [ ...          { ...   ... Read More

How to get the number of siblings of this node in a JTree?

Smita Kapse

Smita Kapse

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

185 Views

To get the count of siblings of this node, use the getSiblingCount() method. Let’s say you have a node with 4 child nodes. Find the sibling of any of this node’s child node. Here, “eight” is the child node −eight.getSiblingCount());Note − Remember, a node is it’s own sibling.The following is ... Read More

Find the count of users who logged in between specific dates with MongoDB

Smita Kapse

Smita Kapse

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

330 Views

Let’s say you have saved the Login date of users. Now, you want the users who logged in between specific dates 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

How to use use an array of pointers (Jagged) in C/C++?

Smita Kapse

Smita Kapse

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

619 Views

Let us consider the following example, which uses an array of 3 integers −In CExample Live Demo#include const int MAX = 3; int main () {    int var[] = {10, 100, 200};    int i;    for (i = 0; i < MAX; i++) {       printf("Value ... Read More

Advertisements