Nancy Den has Published 330 Articles

Get names of all keys in the MongoDB collection?

Nancy Den

Nancy Den

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

1K+ Views

The syntax to get names of all keys in the collection is as follows:var yourVariableName1=db.yourCollectionName.findOne(); for(var yourVariableName 2 in yourVariableName1) { print(yourVariableName); }To understand the above syntax, let us create a collection with documents. The collection name we are creating is “studentGetKeysDemo”.The following is the query to create documents:>db.studentGetKeysDemo.insert({"StudentId":1, ... Read More

How to filter array in subdocument with MongoDB?

Nancy Den

Nancy Den

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

325 Views

You can use aggregate and unwind the array list before applying match. To understand the above concept, let us create a collection with documents. The query to create a collection with document is as follows:> db.filterArray.insertOne( { "L": [{ "N":1 }, { "N":2 } , { "N":3 }, { "N":4 ... Read More

LocalTime compareTo() method in Java

Nancy Den

Nancy Den

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

1K+ Views

Two LocalTime objects can be compared using the compareTo() method in the LocalTime class in Java. This method requires a single parameter i.e. the LocalTime object to be compared.If the first LocalTime object is greater than the second LocalTime object it returns a positive number, if the first LocalTime object ... Read More

Update objects in a MongoDB documents array (nested updating)?

Nancy Den

Nancy Den

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

627 Views

To update the objects in a document’s array, you need to use update() method. To understand the update() method, let us create a collection with document. The query to create a collection with document is as follows:> db.updateObjects.insertOne({"CustomerId":1, "CustomerName":"Larry", "TotalItems":100, ... "ItemDetails":[ ... { ... "NameOfItem":"Item_1", ... "Amount":450 ... }, ... Read More

Query for documents where array size is greater than 1 in MongoDB?

Nancy Den

Nancy Den

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

593 Views

You can use length to query for documents where array size is greater than 1:db.yourCollectionName.find({$where:"this.yourArrayDocumentName.length > 1"}).pretty();To understand the above syntax, let us create a collection with some documents. The query is as follows to create a collection with documents:>db.arrayLengthGreaterThanOne.insertOne({"StudentName":"Larry", "StudentTechnicalSubje ct":["Java", "C", "C++"]}); {    "acknowledged" : true,   ... Read More

LocalDate getMonth() method in Java

Nancy Den

Nancy Den

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

3K+ Views

The month name for a particular LocalDate can be obtained using the getMonth() method in the LocalDate class in Java. This method requires no parameters and it returns the month name in the year.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo {    public ... Read More

LocalTime ofNanoOfDay() method in Java

Nancy Den

Nancy Den

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

74 Views

A LocalTime object can be obtained using the nanoseconds of the day with the ofNanoOfDay() method in the LocalTime class in Java. This method requires a single parameter i.e. the nanoseconds of the day and it returns the LocalTime object for the nanoseconds of the dayA program that demonstrates this ... Read More

LocalDate getYear() method in Java

Nancy Den

Nancy Den

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

5K+ Views

The year for a particular LocalDate can be obtained using the getYear() method in the LocalDate class in Java. This method requires no parameters and it returns the year which can range from MIN_YEAR to MAX_YEAR.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo { ... Read More

How to insert Date value into table in JDBC?

Nancy Den

Nancy Den

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

6K+ Views

You can insert date values in SQL using the date datatype, The java.sql.Date class maps to the SQL DATE type.The PreparedStatement interface provides a method named setDate(). Using this you can insert date into a table. This method accepts two parameters −An integer representing the parameter index of the place ... Read More

How to retrieve Date from a table in JDBC?

Nancy Den

Nancy Den

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

4K+ Views

The ResultSet interface provides a method named getDate() this method accepts an integer parameter representing the index of the column, (or, a String parameter representing the name of the column) from which you need to retrieve the date value. To retrieve date value from a table −Register the driver class ... Read More

Advertisements