Nancy Den has Published 290 Articles

How to get the last N records in MongoDB?

Nancy Den

Nancy Den

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

1K+ Views

To get the last N records in MongoDB, you need to use limit(). The syntax is as follows:db.yourCollectionName.find().sort({$natural:-1}).limit(yourValue);To understand the above syntax, let us create a collection with document. The query to create a collection with document is as follows:> db.getLastNRecordsDemo.insertOne({"EmployeeName":"Maxwell"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf3d6fd07954a4890689") ... Read More

Period plusMonths() method in Java

Nancy Den

Nancy Den

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

143 Views

An immutable copy of the Period object where some months are added to it can be obtained using the plusMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months to be added and it returns the Period object with the added ... Read More

How to change the type of a field in MongoDB?

Nancy Den

Nancy Den

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

2K+ Views

Let us convert string type to int for an example. Aggregation does not allow us to directly change the type of a field; therefore, you need to write a code to convert the type of a field.At first, create a collection with document. After that we will get the type ... Read More

Group by dates in MongoDB?

Nancy Den

Nancy Den

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

586 Views

You can use aggregate framework to group by dates in MongoDB. Let us first create a collection with some documents. The query to create a collection with documents are as follows:> db.groupByDateDemo.insertOne({"UserLoginDateTime":new ISODate()}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ee4df6fd07954a4890695") } > db.groupByDateDemo.insertOne({"UserLoginDateTime":new ISODate("2019-01-31 15:20:09.234Z")}); {    "acknowledged" ... Read More

How can we set time in a table in JDBC?

Nancy Den

Nancy Den

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

320 Views

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

Period plusYears() method in Java

Nancy Den

Nancy Den

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

154 Views

An immutable copy of the Period object where some years are added to it can be obtained using the plusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be added and it returns the Period object with the added ... Read More

Converting string to date in MongoDB?

Nancy Den

Nancy Den

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

1K+ Views

To convert the string to date in MongoDB, use the following syntax:db.yourCollectionName.aggregate(    [       {          $project:          {             anyVariableName:             {                $dateFromString: ... Read More

LocalTime getMinute() method in Java

Nancy Den

Nancy Den

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

182 Views

The minute of the hour for a particular LocalTime can be obtained using the getMinute() method in the LocalTime class in Java. This method requires no parameters and it returns the minute of the hour in the range of 0 to 59.A program that demonstrates this is given as followsExample Live ... Read More

Period minusDays() method in Java

Nancy Den

Nancy Den

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

155 Views

An immutable copy of the Period object where some days are subtracted from it can be obtained using the minusDays() method in the Period class in Java. This method requires a single parameter i.e. the number of days to be subtracted and it returns the Period object with the subtracted ... Read More

8255 Programmable Peripheral Interface Chip

Nancy Den

Nancy Den

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

5K+ Views

Intel 8255 is a peripheral interface (PPI) chip which is programmable. It is used for the connection of peripheral devices and interfacing. We call Peripheral device also as Input Output device. We use Input Output ports for the connection of Input Output devices. Hence 8255 is a programmable Input Output ... Read More

Advertisements