Anvi Jain has Published 569 Articles

RAII and smart pointers in C++

Anvi Jain

Anvi Jain

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

2K+ Views

RAII in C++RAII (Resource Acquisition Is Initialization) is C++ technique which control the life cycle of resource. It is a class variant and is tied to object life time.It encapsulates several resources into class where resource allocation is done by constructor during object creation and resource deallocation is done by ... Read More

How to exclude _id without including other fields using the aggregation framework in MongoDB?

Anvi Jain

Anvi Jain

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

833 Views

Let us first create a collection with documents −> db.excludeIdDemo.insertOne({"StudentFirstName":"John", "StudentAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd701a56d78f205348bc632") } > db.excludeIdDemo.insertOne({"StudentFirstName":"Robert", "StudentAge":20}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd701af6d78f205348bc633") } > db.excludeIdDemo.insertOne({"StudentFirstName":"Chris", "StudentAge":24}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd701b86d78f205348bc634") }Following is the query ... Read More

Querying with MongoDB subelement?

Anvi Jain

Anvi Jain

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

161 Views

You can use positional operator $ for this. Let us first create a collection with documents −> db.subElementQueryingDemo.insertOne( ...    { ...       "ClientName":"Chris", ...       "Status": [ { "isMarried": true }, { "isMarried": false } ] ...    } ... ); {    "acknowledged" : ... Read More

Measure execution time with high precision in C/C++

Anvi Jain

Anvi Jain

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

2K+ Views

To create high precision timer we can use the chrono library. This library has high resolution clock. This can count in nanoseconds.In this program we will see the execution time in nanoseconds. We will take the time value at first, then another time value at the last, then find the ... Read More

Is it possible to achieve a slice chain in MongoDB?

Anvi Jain

Anvi Jain

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

131 Views

Yes, you can achieve this using aggregate framework. Let us first create a collection with documents −> db.sliceOfSliceDemo.insertOne( ...    { ...       "Name": "John", ...       "Details": [["First 1:1", "First 1:2"], ["second 2:1", "Second 2:2"]] ...    } ... ); {    "acknowledged" : true, ... Read More

Update Array element in MongoDB?

Anvi Jain

Anvi Jain

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

227 Views

Use $addToSet operator to update array element. Let us first create a collection with documents −> db.updateArrayDemo.insertOne( ...    { ... ...       "ClientDetails" : [ ...          { ...             "ClientName" : "John", ...           ... Read More

How to Schedule Notification in Android?

Anvi Jain

Anvi Jain

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

630 Views

This example demonstrate about How to schedule notification in android.Step 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 code to res/layout/activity_main.xml. Step 3 − Add the following code ... Read More

Is there any way to see the MongoDB results in a better format?

Anvi Jain

Anvi Jain

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

118 Views

Yes, you can use the findOne(). Following is the syntax −db.yourCollectionName.findOne();You can use toArray() as well −db.yourCollectionName.find().toArray();Let us first create a collection with documents −> db.betterFormatDemo.insertOne({"StudentName":"Adam Smith", "StudentScores":[98, 67, 89]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7ab826d78f205348bc640") } > db.betterFormatDemo.insertOne({"StudentName":"John Doe", "StudentScores":[67, 89, 56]}); {    "acknowledged" : ... Read More

How to delete a table from MongoDB database?

Anvi Jain

Anvi Jain

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

511 Views

Use drop() to delete a table. Following is the syntax −db.yourCollectionName.drop();Let us first create a collection with documents −> db.deleteTableDemo.insertOne({"Name":"Chris", "Age":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccfb705140b992277dae0e6") } > db.deleteTableDemo.insertOne({"Name":"Carol", "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccfb70c140b992277dae0e7") } > db.deleteTableDemo.insertOne({"Name":"David", "Age":24}); {    "acknowledged" ... Read More

The best way to hide a string in binary code in C++?

Anvi Jain

Anvi Jain

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

643 Views

Here we will see how to hide some string into some binary code (Here binary code is represented in hexadecimal number).The approach is very simple. We can use the string stream to convert decimal number to hexadecimal numbers. Now from the string, we will read each character, and take its ... Read More

Advertisements