Anvi Jain has Published 569 Articles

Find value in a MongoDB Array with multiple criteria?

Anvi Jain

Anvi Jain

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

532 Views

To find value in the array with multiple criteria, for example, you can use $elemMatch along with $gt and $lt. The syntax is as follows −db.yourCollectionName.find({yourFieldName:{$elemMatch:{$gt:yourNegativeValue, $lt:yourPo sitiveValue}}}).pretty();To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is ... Read More

What is a reentrant function in C/C++?

Anvi Jain

Anvi Jain

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

4K+ Views

Here we will see what is the reentrant function in C or C++. One function is said to be a reentrant function if there is a provision to interrupt that function in the course of execution, then service the ISR (Interrupt Service Routine) and then resume the task. This type ... Read More

Collectors.joining() method in Java 8

Anvi Jain

Anvi Jain

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

2K+ Views

The joining() method of the Collectors class in Java 8 returns a Collector that concatenates the input elements into a String, in encounter order.The syntax is as follows −public static Collector joining()Here, CharSequence is a readable sequence of char values, whereas String class represents character strings.To work with Collectors class ... Read More

How to write a singleton class in C++?

Anvi Jain

Anvi Jain

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

1K+ Views

Singleton design pattern is a software design principle that is used to restrict the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. For example, if you are using a logger, that writes logs to a file, ... Read More

Multiline macros in C

Anvi Jain

Anvi Jain

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

4K+ Views

In this section we will see, how can write multiline macros in C. We can write multiline macros like functions, but for macros, each line must be terminated with backslash ‘\’ character. If we use curly braces ‘{}’ and the macros is ended with ‘}’, then it may generate some ... Read More

Get the storage size of a database in MongoDB?

Anvi Jain

Anvi Jain

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

1K+ Views

To get the storage size of a database in MongoDB, use the stats() method.At first, check the current database with the help of the following query −> db;The following is the output −testHere is the query to get the storage size of the database in MongoDB −> db.stats()The following is ... Read More

Select MongoDB documents where a field either does not exist, is null, or is false?

Anvi Jain

Anvi Jain

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

403 Views

You can use $in operator for this. Let us first create a collection with a document. The query to create a collection with a document is as follows −> db.selectMongoDBDocumentsWithSomeCondition.insertOne({"StudentId":1, "StudentName":"Larry"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9010215705caea966c557f") } > db.selectMongoDBDocumentsWithSomeCondition.insertOne({"StudentId":2, "StudentName":"Mike", "hasAgeGreaterThanOrEqualTo18":true}); {    "acknowledged" : true, ... Read More

How does free() know the size of memory to be deallocated?

Anvi Jain

Anvi Jain

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

2K+ Views

The free() function is used to deallocate memory while it is allocated using malloc(), calloc() and realloc(). The syntax of the free is simple. We simply use free with the pointer. Then it can clean up the memory.free(ptr);The free() is not taking any size as parameter, but only pointer. So ... Read More

Insert records in MongoDB collection if it does not exist?

Anvi Jain

Anvi Jain

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

2K+ Views

You can use update() function to insert records in MongoDB if it does not exist. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.insertIfNotExistsDemo.insertOne({"StudentName":"Mike", "StudentAge":21}); {    "acknowledged" : true,    "insertedId" : ... Read More

How to modify a const variable in C?

Anvi Jain

Anvi Jain

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

6K+ Views

In C or C++, we can use the constant variables. The constant variable values cannot be changed after its initialization. In this section we will see how to change the value of some constant variables.If we want to change the value of constant variable, it will generate compile time error. ... Read More

Advertisements