Find a Value in Lowercase from a MongoDB Collection

AmitDiwan
Updated on 27-Mar-2020 06:45:06

3K+ Views

To find a value in lowercase, use the toLowerCase() method in MongoDB. Use the method in find() to find the value in lowercase.Let us create a collection with documents −> db.demo172.insertOne({"SubjectName":"MySQL"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e3838ce9e4f06af551997e1") } > db.demo172.insertOne({"SubjectName":"mongodb"}); {     "acknowledged" : true,    "insertedId" : ObjectId("5e3838d69e4f06af551997e2") } > db.demo172.insertOne({"SubjectName":"MongoDB"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5e3838db9e4f06af551997e3") }Display all documents from a collection with the help of find() method −> db.demo172.find();This will produce the following output −{ "_id" : ObjectId("5e3838ce9e4f06af551997e1"), "SubjectName" : "MySQL" } { "_id" : ObjectId("5e3838d69e4f06af551997e2"), "SubjectName" : "mongodb" } ... Read More

Re-map Fields of a MongoDB Collection

AmitDiwan
Updated on 27-Mar-2020 06:40:03

257 Views

To re-map the fields of a MongoDB collection, use update() along with $rename. Let us first create a collection with documents −> db.demo171.insertOne( { "Name": "Chris", "Details": { "SubjectName": "MySQL", "CountryName": "US" } } ); {    "acknowledged" : true,    "insertedId" : ObjectId("5e3837 399e4f06af551997e0") }Display all documents from a collection with the help of find() method −> db.demo171.find();This will produce the following output −{ "_id" : ObjectId("5e3837399e4f06af551997e0"), "Name" : "Chris", "Details" : { "SubjectName" : "MySQL", "CountryName" : "US" } }Following is the query to re-map the fields of a MongoDB collection −> db.demo171.update({}, { $rename : { 'Name' ... Read More

Purpose of Using jlink in Java 9

raja
Updated on 26-Mar-2020 14:25:18

199 Views

The main purpose of the JLink feature is to create our own Customized JRE. Usually, we run a program with the default JRE that has been provided by Oracle Corporation with 214 MB of size.For instance, a user wants to print a simple "Hello World" message as shown belowpublic class HelloWorldModuleTest {    public static void main(String args[[]) {       System.out.println("Hello World!");    } }To run the above program of 1 KB size, we need 4 – 5 classes like String, System, Object, and HelloWorldModuleTest.class files. Then why do we need to load 214 MB of JRE using ... Read More

Importance of Module Descriptor in Java 9

raja
Updated on 26-Mar-2020 10:44:32

732 Views

A module is a collection of code in the form of classes organized in packages and static resources such as property files or others. It provides the outside environment with all the information that can be required to use that module. The module descriptor is a key source of the module system, and it's compiled version of a module declaration specified in a file named "module-info.java" file at the root of the module’s directory hierarchy.The module describes itself by a module declaration as belowmodule com.myproject.module1 {    requires com.myproject.module2;    exports com.myproject.project1;    exports com.myproject.project2; }Below are some of the module descriptors described:module module. name: declares a module ... Read More

Edit CSV File Using PowerShell

Chirag Nagrekar
Updated on 26-Mar-2020 07:32:48

7K+ Views

To edit the CSV file using PowerShell, you need to use the below commands.We already have the CSV file output.csv, we will import this file first.$csvfile = Import-csv C:\temp\Outfile.csvOutputBelow is the output of the CSV file.EMP_Name    EMP_ID     CITY --------    ------     ---- Charles     2000       New York James       2500       Scotland Charles     3000       PolandWe need to update the above file. We will change the CITY of the EMP_ID ‘3000’ to MUMBAI. If we update the CITY name by the EMP_Name, it ... Read More

Append Data into a CSV File using PowerShell

Chirag Nagrekar
Updated on 26-Mar-2020 07:28:05

43K+ Views

To append the data into CSV file you need to use –Append parameter while exporting to the CSV file.In the below example, we have created a CSV fileExample$outfile = "C:\temp\Outfile.csv" $newcsv = {} | Select "EMP_Name", "EMP_ID", "CITY" | Export-Csv $outfile $csvfile = Import-Csv $outfile $csvfile.Emp_Name = "Charles" $csvfile.EMP_ID = "2000" $csvfile.CITY = "New York" $csvfile | Export-CSV $outfile Import-Csv $outfileNow we need to append the below data to the existing file. So first we will import the csv file into a variable called $csvfile$csvfile = Import-Csv $outfile $csvfile.Emp_Name = "James" $csvfile.EMP_ID = "2500" $csvfile.CITY = "Scotland"Once data is inserted into ... Read More

Create a CSV File Manually in PowerShell

Chirag Nagrekar
Updated on 26-Mar-2020 07:23:52

5K+ Views

There are few methods to create a CSV file in the PowerShell, but we will use the best easy method to create it.First, to create a CSV file in PowerShell, we need to create headers for it. But before it, we need output file name along with its path.$outfile = "C:\temp\Outfile.csv"Here we have given output file name Outfile.csv in the path C:\temp.Now we will create headers, $newcsv = {} | Select "EMP_Name", "EMP_ID", "CITY" | Export-Csv $outfileHere, we have created a CSV file and exported a file to the newly created file.We will now import this file to check if ... Read More

Export and Import CSV File Manually in PowerShell

Chirag Nagrekar
Updated on 26-Mar-2020 07:19:32

2K+ Views

When you run a command Export-Csv in PowerShell, it automatically creates a CSV file to the specific location.ExampleGet-Service | Select Name, Starttype, Status | Export-Csv C:\temp\services.csv -NoTypeInformationIn the above example, Services.csv file created in C:\Temp folders with the header Name, Starttype, and Status headers.Similarly, you can use the other commands to get the output into the CSV file format.If you want to check this file from the PowerShell console, you need to use Import-CSV command.Import-Csv C:\temp\Services.csv | ft -AutosizeOutputName                                     StartType     ... Read More

Use Custom Headers in PowerShell Output Table

Chirag Nagrekar
Updated on 26-Mar-2020 07:07:34

6K+ Views

If you want the specific properties in PowerShell, you need to use the Select-Object (Alias − Select) as a pipeline.In the below example, we will retrieve the specific properties of the Spooler service.ExampleGet-Service Spooler | Select Name, DisplayName, Starttype, StatusOutputName       DisplayName    StartType    Status ----       -----------    ---------    ------ Spooler    Print Spooler  Automatic    RunningNow we will customize the header by renaming the “Name” property to the “Alias Name” by the Name and the Expression syntax inside the Select-object.ExampleGet- Service Spooler | Select @{N='Alias Name';E={$_.Name}}, DisplayName, Starttype, StatusYou can also use ... Read More

Output Formatting in PowerShell

Chirag Nagrekar
Updated on 26-Mar-2020 07:03:15

598 Views

In PowerShell, the output is in the default table format. To format the output in the desired format, mainly below pipeline commands are used.Format-TableFormat-ListFormat-WideThere are also commands to format the output data but not used widely.Format-CustomFormat-HexIn the below example, we will get the service's details using Get-Service and format it using the different output cmdlets.Get-Service WinRM, SpoolerOutputStatus     Name        DisplayName ------     ----        ----------- Running    Spooler     Print Spooler Stopped    WinRM       Windows Remote Management (WS-Manag...As you can see Display Name for the WinRM service is not ... Read More

Advertisements