In order to list all users in the Mongo shell, use the getUsers() method or show command.Case 1 − Using getUsers()The syntax is as follows −db.getUsers();Case 2 − Using show commandThe syntax is as follows −show users;Let us implement both the syntaxes in order to list all users in the Mongo shell.Case 1 − The first query is as follows −> db.getUsers();The following is the output −[ { "_id" : "test.John", "user" : "John", "db" : "test", "roles" : [ { ... Read More
A RowSet object is similar to ResultSet, it also stores tabular data, in addition to the features of a ResultSet. A RowSet follows the JavaBeans component model.If you Retrieve a ResultSet object by default the cursor of it moves only in forward direction. i.e. you can retrieve the contents of it from first to last.But, in a scrollable result set, the cursor can scroll forward and backward and you can retrieve data backward too.To make ResultSet object scrollable, you need to create one as shown below −Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);Whereas, a RowSet object is Scrollable by default. Therefore, whenever ... Read More
To add a new item to an array, you can use $push operator. Let us first implement the following query to create a collection with documents:> db.updateDemo.insertOne({"StudentName":"Larry", "StudentCoreSubject":["Java", "C"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c98ba78330fd0aa0d2fe4c9") } >db.updateDemo.insertOne({"StudentName":"Robert", "StudentCoreSubject":["C++", "MongoDB"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c98ba8b330fd0aa0d2fe4ca") } > db.updateDemo.insertOne({"StudentName":"Chris", "StudentCoreSubject":["Python"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c98ba9b330fd0aa0d2fe4cb") }Following is the query to display all the documents from a collection with the help of find() method> db.updateDemo.find().pretty();This will produce the following output{ "_id" : ObjectId("5c98ba78330fd0aa0d2fe4c9"), "StudentName" : "Larry", "StudentCoreSubject" : [ ... Read More
To make an http request in iOS we’ll make use of DataTask and sessions. We’ll create configuration, sessions, url, request, and dataTask objects. Let’s see the steps that we’ll go through.The HTTP request can be of different types, it depends on what kind of request we want to make to our server. Below are the basic types of requests.“GET”, ”POST”, ”PUT”, ”DELETE” , we can make use of any of these according to our API. The basics remain same for each kind of request, which are shown below. Let’s see these examples with DELETE type of request.First of all we ... Read More
If a directed graph is given, determine if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. Reachable mean that there is a path from vertex i to j. This reach-ability matrix is called transitive closure of a graph. Warshall algorithm is commonly used to find the Transitive Closure of a Given Graph G. Here is a C++ program to implement this algorithm.AlgorithmBegin 1. Take maximum number of nodes as input. 2. For Label the nodes as a, b, c….. 3. To check if there any edge ... Read More
A Hamiltonian cycle is a Hamiltonian Path such that there is an edge (in graph) from the last vertex to the first vertex of the Hamiltonian Path. It is in an undirected graph is a path that visits each vertex of the graph exactly once.Functions and purposesBegin 1. function isSafe() is used to check for whether it is adjacent to the previously added vertex and already not added. 2. function hamiltonianCycle() solves the hamiltonian problem. 3. function hamCycle() uses hamiltonianCycle() to solve the hamiltonian problem. It returns false if there is no Hamiltonian Cycle possible, ... Read More
Before we even start discussing the space and weight constraints of a laptop, many customized/personalized Apps Have Arrived: a touch bar therefore, is a strip of touch-sensitive, context-aware display that replaces the function keys seen in a traditional keyboard.Applications for EventsFor example, in Apple iPhones, the App called ‘Siri’ is also a permanent addition to the touch bar and it is located on the far right-hand side. There are others who state that Windows 10 S is the future of the desktop PC. The Desktop PC which was at one point considered a novelty is now more of an obsolete piece ... Read More
Unfortunately, in the Indian education system, we are more concerned about scores on the exams rather than the knowledge. We consider that grades are the only measure of college success. In some sense that is also true because of the competition in the job market.Let us look at some tips to score well in college exams:Since you are out of high school, the first thing you have to learn is taking charge of your life. So step up to bat and take responsibility.Pick up the right courses. Make a balance between the interesting and scoring subjects. But take care that ... Read More
The fixed instant on the clock can be obtained using the method fixed() in the Clock Class in Java. This method requires two parameters i.e. the fixed instant and the time zone. Also, it returns the fixed instant on the clock. The fixed() method is normally used for testing purposes.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); ZoneId zId = ZoneId.of("Australia/Melbourne"); ... Read More
With JSP program, it is very easy to get the current date and the time. You can use a simple Date object with the toString() method to print the current date and the time as follows −Example Live Demo Display Current Date & Time Display Current Date & Time Let us now keep the code in CurrentDate.jsp and then call this JSP using the URL http://localhost:8080/CurrentDate.jsp. You will receive the following result −OutputDisplay ... Read More