Query Internal Array Size in MongoDB

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

215 Views

You can use the $size operator for internal array size in MongoDB. The syntax is as follows:db.internalArraySizeDemo.aggregate(    [       {          $group: {             _id:yourObjectIdValue,             anyFieldName: {$first: {$size: "$yourArrayName" }}          }       }    ] );To understand the above syntax, let us create a collection with some documents. The query to create a collection with documents are as follows:>db.internalArraySizeDemo.insertOne({"EmployeeName":"Mike", "EmployeeTechnology":["Jav a Web Development", "Python Web Development"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6eff586fd07954a48906b2") } > ... Read More

What is a Config Object in JSP

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

427 Views

The config object is an instantiation of javax.servlet.ServletConfig and is a direct wrapper around the ServletConfig object for the generated servlet.This object allows the JSP programmer access to the Servlet or JSP engine initialization parameters such as the paths or file locations etc.The following config method is the only one you might ever use, and its usage is trivial −config.getServletName();This returns the servlet name, which is the string contained in the element defined in the WEB-INF\web.xml file.

Store Decimal Value in Android SQLite

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

725 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to store decimal value in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More

Period hashCode Method in Java

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

144 Views

The hash code value of the Period can be obtained using the hashCode() method in the Period class in Java. This method requires no parameters and it returns the hash code value of the Period.A program that demonstrates this is given as follows:Example Live Demoimport java.time.Period; public class Demo {    public static void main(String[] args) {       String period = "P5Y7M15D";       Period p = Period.parse(period);       System.out.println("The Period is: " + p);       System.out.println("The hash code is: " + p.hashCode());    } }OutputThe Period is: P5Y7M15D The hash code is: 984837Now ... Read More

Serial Line Internet Protocol (SLIP)

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

7K+ Views

Serial Line Internet Protocol (SLIP) is a simple protocol that works with TCP/IP for communication over serial ports and routers. They provide communications between machines that were previously configured for direct communication with each other.For example, a client may be connected to the Internet service provider (ISP) with a slower SLIP line. When a service is required, the client places a request to the ISP. The ISP responds to the request and passes it over to the Internet via high speed multiplexed lines. The ISP then sends the results back to the client via the SLIP lines.SLIP was developed by ... Read More

Find Minimum Unused Value in a MySQL Table

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

258 Views

You can use LEFT JOIN to find minimum unused value in a MySQL table. Let us first create a tablemysql> create table FindValue    -> (    -> SequenceNumber int    -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into FindValue values(109); Query OK, 1 row affected (0.14 sec) mysql> insert into FindValue values(110); Query OK, 1 row affected (0.15 sec) mysql> insert into FindValue values(111); Query OK, 1 row affected (0.13 sec) mysql> insert into FindValue values(113); Query OK, 1 row affected (0.13 ... Read More

Fetch Value from Key-Value Tuple in Java

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

213 Views

To fetch the value from a KeyValue tuple in Java, use the getValue() method. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:Steps: How to run JavaTuples program in EclipseThe following is an example to fetch the ... Read More

Make Layout Scroll Vertically

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

326 Views

Before getting into example , we should know what is vertical Scroll View(Scroll View). Vertical Scroll view provide by android.widget.ScrollView class . It is used to scroll child views in vertical direction.This example demonstrate about how to use Vertical Scroll view.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.                                                   ... Read More

Add New Property to Each Document in a Large MongoDB Collection

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

834 Views

You can use update command along with forEach() for large collection. Let us first create a collection with documents>db.addingNewPropertyDemo.insertOne({"StudentName":"John", "StudentAge":23, "CountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca1e61866324ffac2a7dc56") } >db.addingNewPropertyDemo.insertOne({"StudentName":"David", "StudentAge":21, "CountryName":"AUS"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca1e62366324ffac2a7dc57") } >db.addingNewPropertyDemo.insertOne({"StudentName":"Bob", "StudentAge":21, "CountryName":"UK"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca1e62d66324ffac2a7dc58") }Following is the query to display all documents from a collection with the help of find() method> db.addingNewPropertyDemo.find().pretty();This will produce the following output{    "_id" : ObjectId("5ca1e61866324ffac2a7dc56"),    "StudentName" : "John",    "StudentAge" : 23,    "CountryName" : "US" } {    "_id" : ... Read More

Create Java Priority Queue to Ignore Duplicates

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

1K+ Views

The simplest way to create a Java Priority Queue to ignore duplicates is to first create a Set implementation −HashSet set = new HashSet (); set.add(100); set.add(150); set.add(250); set.add(300); set.add(250); set.add(500); set.add(600); set.add(500); set.add(900);Now, create Priority Queue and include the set to remove duplicates in the above set −PriorityQueuequeue = new PriorityQueue(set);Example Live Demoimport java.util.HashSet; import java.util.PriorityQueue; public class Demo {    public static void main(String[] args) {       HashSetset = new HashSet();       set.add(100);       set.add(150);       set.add(250);       set.add(300);       set.add(250);       set.add(500); ... Read More

Advertisements