Smita Kapse has Published 498 Articles

How to retrieve a nested object in MongoDB?

Smita Kapse

Smita Kapse

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

1K+ Views

To retrieve a nested object in MongoDB, use $ operator. Let us first create a collection with documents −> db.queryNestedObject.insertOne( ...    { ...       "StudentName" : "James", ...       "StudentSubjectScore" : [ ...          {"StudentMongoDBScore":98}, ...          {"StudentCScore":92}, ... ... Read More

How to calculate timestamp difference in hours with MongoDB?

Smita Kapse

Smita Kapse

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

928 Views

To calculate timestamp difference, use aggregate framework. Let us first create a collection with documents −> db.timestampDifferenceDemo.insertOne({    "MovieBeginningTime": new ISODate("2019-05-12 10:20:30"),    "MovieEndingTime":new ISODate("2019-05-12 12:30:20") }); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7ba1f6d78f205348bc644") } > db.timestampDifferenceDemo.insertOne({    "MovieBeginningTime": new ISODate("2019-05-12 04:00:00"),    "MovieEndingTime":new ISODate("2019-05-12 07:10:00") }); { ... Read More

Reverse a string in C/C++ using Client Server model

Smita Kapse

Smita Kapse

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

1K+ Views

Here we will see how we can create a system, where we will create one client, and a server, and the client can send one string to the server, and the server will reverse the string, and return back to the client.Here we will use the concept of socket programming. ... Read More

How to schedule local notifications in Android?

Smita Kapse

Smita Kapse

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

2K+ Views

This example demonstrate about How to schedule local 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 ... Read More

Display distinctly ordered MongoDB record with skip and limit?

Smita Kapse

Smita Kapse

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

843 Views

You can work with aggregate framework and use $sort, $skip and $limit to display distinctly ordered records with skip and also set the limit. Let us first create a collection with documents> db.orderedDistinctDemo.insertOne({"Name":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccfb8e0140b992277dae0e9") } > db.orderedDistinctDemo.insertOne({"Name":"Larry"}); {    "acknowledged" : true, ... Read More

Java Program to create DefaultTableModel from two dimensional array

Smita Kapse

Smita Kapse

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

463 Views

The DefaultTableModel is an implementation of TableModel that uses a Vector of Vectors to store the cell value objects. At first create a two dimensional array for rows and columns −DefaultTableModel tableModel = new DefaultTableModel(new Object[][] {    { "India", "Asia" }, { "Canada", "North America" }, { "Singapore", "Asia" ... Read More

How do I add a field to existing record in MongoDB?

Smita Kapse

Smita Kapse

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

356 Views

You can use update command to add a field to existing record. Let us first create a collection with documents −> db.addAFieldToEveryRecordDemo.insertOne({"ClientName":"Chris", "ClientAge":34}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd00e32588d4a6447b2e061") } > db.addAFieldToEveryRecordDemo.insertOne({"ClientName":"Robert", "ClientAge":36}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd00e59588d4a6447b2e062") }Following is the query to ... Read More

Inserting an Image into a JTextPane Component with Java

Smita Kapse

Smita Kapse

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

682 Views

Let’s say the following is our JTextPane with orange background color −JTextPane textPane = new JTextPane(); textPane.setBackground(Color.orange);Now, set the style and attributes. Also, set the font −SimpleAttributeSet attributeSet = new SimpleAttributeSet(); StyleConstants.setItalic(attributeSet, true); textPane.setCharacterAttributes(attributeSet, true); textPane.setText("Recall this and "); Font font = new Font("Verdana", Font.BOLD, 22); textPane.setFont(font);After the text displayed ... Read More

What is the difference between const int*, const int * const, and int const *?

Smita Kapse

Smita Kapse

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

553 Views

Here we will see some different types of variable declaration based on integer pointers integer constants and the integer constant pointers.To determine them we will use the Clockwise/Spiral Rule. By discussing the terms, we can understand the rules also.The const int *. This is used to tell the compiler that ... Read More

Delete data from a collection in MongoDB using multiple conditions?

Smita Kapse

Smita Kapse

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

1K+ Views

You can use remove() for this. Let us first create a collection with documents −> db.deleteDataDemo.insertOne({_id:1, "Name":"Larry"}); { "acknowledged" : true, "insertedId" : 1 } > db.deleteDataDemo.insertOne({_id:2, "Name":"Chris"}); { "acknowledged" : true, "insertedId" : 2 } > db.deleteDataDemo.insertOne({_id:3, "Name":"Robert"}); { "acknowledged" : true, "insertedId" : 3 } > db.deleteDataDemo.insertOne({_id:4, "Name":"David"}); ... Read More

Advertisements