Arjun Thakur has Published 1025 Articles

Can we use NOT and AND together in MongoDB?

Arjun Thakur

Arjun Thakur

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

239 Views

Yes, we can use the NOT and AND together in MongoDB. The syntax is as followsNOT X AND NOT Y = NOT (X AND Y) Let us see the working of above syntax. If both X and Y will be true then last result will be false. If one of ... Read More

Search for a value in Java KeyValue Tuple

Arjun Thakur

Arjun Thakur

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

119 Views

To search for a value in KeyValue Tuple, use the contains() method. Here, the value to be searched should be set as the parameter of the method. The return value is a boolean i.e. TRUE, if the value exists, else FALSE. Let us first see what we need to work ... Read More

How to get embedded data in a MongoDB document?

Arjun Thakur

Arjun Thakur

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

283 Views

Following is the syntax to get the embedded data in a MongoDB documentdb.yourCollectionName.find({}, {‘yourOuterKeyName.yourInnerKeyName:1}).pretty();Let us first create a collection with documents> db.embeddedCollectionDemo.insertOne( ...    { ...       "StudentName" : "Larry", ...       "StudentDetails": { ...          "Larry1234": {"ProjectName": "Student Web Tracker"}, ...   ... Read More

Get only the FALSE value with MongoDB query

Arjun Thakur

Arjun Thakur

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

202 Views

To get only the FALSE value, let us first create a collection with documents. One of the fields is isEnable that is having TRUE or FALSE values as shown below> db.translateDefinitionDemo.insertOne({"_id":10, "StudentName":"Larry", "isEnable":true}); { "acknowledged" : true, "insertedId" : 10 } > db.translateDefinitionDemo.insertOne({"_id":20, "StudentName":"Chris", "isEnable":false}); { "acknowledged" : true, "insertedId" ... Read More

Where is the MySQL database gets saved when it is created?

Arjun Thakur

Arjun Thakur

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

476 Views

If you want the database location i.e. where it is created in MySQL, you can use system variable @@datadir.The syntax is as followsSELECT @@datadir;The following is the querymysql> select @@datadir;Here is the output. The above query returns the location+---------------------------------------------+ | @@datadir ... Read More

The lastIndexOf() method of AbstractList class in Java

Arjun Thakur

Arjun Thakur

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

102 Views

The lastIndexOf() method of the AbstractList return the index of the last occurrence of an element in the list. If the element does not exist in the list, then -1 is returned.The syntax is as followspublic int lastIndexOf(Object ob)Here, the parameter ob is the element to be searched. To work ... Read More

How to update a MongoDB document for adding a new item to an array?

Arjun Thakur

Arjun Thakur

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

236 Views

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" : ... Read More

C++ Program to Find the Transitive Closure of a Given Graph G

Arjun Thakur

Arjun Thakur

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

256 Views

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 ... Read More

How to implement GROUP by range in MySQL?

Arjun Thakur

Arjun Thakur

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

1K+ Views

To group by range in MySQL, let us first create a table. The query to create a table is as followsmysql> create table GroupByRangeDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > YourRangeValue int    - > ); Query OK, 0 ... Read More

LongStream.Builder build() method in Java

Arjun Thakur

Arjun Thakur

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

119 Views

The build() method of the LongStream.Builder class builds the stream, transitioning this builder to the built state.The syntax is as followsLongStream build()To use the LongStream.Builder class in Java, import the following packageimport java.util.stream.LongStream;The following is an example to implement LongStream.Builder build() method in JavaExample Live Demoimport java.util.stream.LongStream; public class Demo { ... Read More

Advertisements