Get Output of MongoDB Shell Script

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

843 Views

You can use printjson() or print() to get output of MongoDB shell script. Let us create an array of objects.Following is the query to create an array of objects.> var studentDetails=[{"StudentName":"John","StudentAge":21},    {"StudentName":"Carol","StudentAge":24},{"StudentName":"David","StudentAge":25}];Following is the query to get the output of Mongo shell script using printjson() −> printjson(studentDetails);This will produce the following output −[    {       "StudentName" : "John",       "StudentAge" : 21    },    {       "StudentName" : "Carol",       "StudentAge" : 24    },    {       "StudentName" : "David",       "StudentAge" : 25    } ] > var studentDetails=[{"StudentName":"John","StudentAge":21},    {"StudentName":"Carol","StudentAge":24},{"StudentName":"David","StudentAge":25}];

Pull Multiple Objects from an Array in MongoDB

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" : [ ...          { ...             "ClientCountryName" : "US", ...             "ClientProjectName" : "Online Book Store", ... ...          }, ...          { ...             "ClientCountryName" : "AUS", ...     ... Read More

What is Double Buffering in Java

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

2K+ Views

Double-buffering is the process of drawing graphics into an off-screen image buffer and then copying the contents of the buffer to the screen all at once.For the complex graphics, using double-buffering can reduce flickering issues.Java Swing automatically supports double-buffering for all of its components.Double-buffering is memory intensive, its use is only justified for components that are repainted very frequently or have particularly complex graphics to display.If a container uses double-buffering, any double-buffered children it has shared the off-screen buffer of the container, the required off-screen buffer is never larger than the on-screen size of the application.To enable double buffering, simply ... Read More

Check If Value Exists in Array Property in MongoDB Query

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"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd684d87924bb85b3f4895b") }Following is the query to display all documents from a collection with the help of find() method −> db.valueInArrayDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd684cf7924bb85b3f48959"),    "UserName" : "John",    "UserMessage" : [       "Hi",       "Hello",     ... Read More

Bind Function and Placeholders in C++

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 to do such manipulating in some easier fashion. To use these features, we have to use header file.Bind functions with the help of placeholders helps to determine the positions, and number of arguments to modify the function according to desired outputs.Placeholders are namespaces which detect the position of a ... Read More

Convert String to Enum in Java

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

3K+ Views

The valueOf() method of the Enum class in java accepts a String value and returns an enum constant of the specified type.ExampleLet us create an enum with name Vehicles with 5 constants representing models of 5 different scoters with their prices as values, as shown below −enum Vehicles { //Constants with values ACTIVA125(80000), ACTIVA5G(70000), ACCESS125(75000), VESPA(90000), TVSJUPITER(75000); //Instance variable private int price; //Constructor to initialize the instance variable Vehicles(int price) { this.price = price; } ... Read More

HTML DOM Input FileUpload Type Property

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

163 Views

The HTML DOM input FileUpload type property returns the value of type attribute of an element in an HTML document.SyntaxFollowing is the syntax −object.typeExampleLet us see an example of HTML DOM input file upload type property − Live Demo    body{       text-align:center;       background-color:#52B2CF;       color:#fff;    }    .btn{       background-color:coral;       border:none;       height:2rem;       border-radius:50px;       width:60%;       margin:1rem auto;       display:block;       color:#fff;       outline:none;    }   ... Read More

Use of Parenthesis and Brackets in Accessing a Function in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

510 Views

The ()(parenthesis) brackets play an important role in accessing a function. Accessing a function without () will return the function definition instead of the function result. If the function is accessed with () then the result can be obtained.Without ()ExampleIn the following example, the function is accessed without () so the function definition is returned instead of the result as shown in the output.Live Demo function toCelsius(f) { return (5/9) * (f-32); } document.write(toCelsius); Outputfunction toCelsius(f) { return (5/9) * (f-32); ... Read More

Transform List of Strings to Upper Case in Java

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

4K+ Views

Let’s first create a List string:List list = Arrays.asList("David", "Tom", "Ken", "Yuvraj", "Gayle");Now transform the above list to upper case:list.stream().map(players -> players.toUpperCase())To display, use forEach():list.stream().map(players -> players.toUpperCase()) .forEach(players -> System.out.print(players + ""));The following is an example to transform List string to upper case:Exampleimport java.util.Arrays; import java.util.List; public class Demo {    public static void main(final String[] args) {       List list = Arrays.asList("David", "Tom", "Ken", "Yuvraj", "Gayle");       System.out.print("List = "+list);       System.out.print("Uppercase strings = ");       list.stream().map(players -> players.toUpperCase()) .forEach(players -> System.out.print(players + ""));    } }OutputList = [David, Tom, Ken, ... Read More

Create and Manage Notification Channels in Android

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

3K+ Views

This example demonstrate about Create and Manage Notification Channels 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 code to res/layout/activity_main.xml.     Step 3 − Add a sound into raw folderStep 4 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.content.ContentResolver ; import android.content.Context ; import android.graphics.Color ; import android.media.AudioAttributes ; import android.net.Uri ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import ... Read More

Advertisements