Smita Kapse has Published 558 Articles

How do I drop a MongoDB database from the command line?

Smita Kapse

Smita Kapse

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

240 Views

To drop a MongoDB database from the command line, use the following syntax:mongo yourDatabaseName --eval "db.dropDatabase()"To understand the above syntax, let us display all the database from MongoDB. The query is as follows −> show dbs;The following is the output −StudentTracker 0.000GB admin 0.000GB config 0.000GB local 0.000GB sample 0.000GB ... Read More

LongStream flatMap() method in Java

Smita Kapse

Smita Kapse

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

58 Views

The flatMap() method in LongStream class returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.The syntax is as follows −LongStream flatMap(LongFunction

Fetch the value from an Octet Tuple in Java

Smita Kapse

Smita Kapse

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

70 Views

To fetch the value from an Octet Tuple, use the getValueX() method. Here X is the index for which you want the value.For example, to fetch the 5th element i.e. 4th index, use the getValueX() method as −getValue(4);Let us first see what we need to work with JavaTuples. To work ... Read More

How to delete everything in a MongoDB database?

Smita Kapse

Smita Kapse

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

426 Views

You can delete everything in a MongoDB database using dropDatabase() function. The syntax is as follows −use yourDatabaseName; db.dropDatabase();The above syntax will delete everything in a MongoDB database.To delete everything in a MongoDB database, let us first display all the databases from MongoDB. The query is as follows −> show ... Read More

Is it possible to cast in a MongoDB Query?

Smita Kapse

Smita Kapse

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

235 Views

Yes, it is possible to cast in a MongoDB query −db.yourCollectionName.find("this.yourFieldName >yourValue);To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.castingDemo.insertOne({"Amount":"200"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c947e874cf1f7a64fa4df42") } > db.castingDemo.insertOne({"Amount":"100"}); { ... Read More

Convert between binary and ASCII using Python (binascii)

Smita Kapse

Smita Kapse

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

783 Views

The binascii module enables conversion between binary and various ASCII encoded binary representations. The binascii module contains low-level functions written in C for greater speed. They are used by the higher-level modules such as uu, base64 or binhex modules.The binascii module defines the following functions. These function are named as ... Read More

The iterator() method of Java AbstractCollection class

Smita Kapse

Smita Kapse

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

92 Views

The iterator() method of the AbstractCollection class in Java is used to return an iterator over the elements contained in this collection.The syntax is as follows −public abstract Iterator iterator()To work with AbstractCollection class in Java, import the following package −import java.util.AbstractCollection;For Iterator, import the following package −import java.util.Iterator;The following ... Read More

How to work Date query with ISODate in MongoDB?

Smita Kapse

Smita Kapse

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

2K+ Views

Use $gte operator along with ISODate() to work Date query with ISODate in MongoDB.To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.dateDemo.insertOne({"StudentName":"John", "StudentAge":26, "AdmissionDate":new ISODate("2013-06-07")}); {    "acknowledged" : true,    "insertedId" : ... Read More

MySQL SELECT from table A that does not exist in table B using JOINS?

Smita Kapse

Smita Kapse

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

2K+ Views

To SELECT from table A that does not exist in table B, you can use left join. Following is the syntax −select yourTableNameA.* from yourTableNameA left join yourTableNameB on yourTableNameA.yourColumnName = yourTableNameB.yourColumnName where yourTableNameB.yourColumnName IS NULL;Let us first create a table. Following is the query −mysql> create table table_A   ... Read More

Achieve Pagination with MongoDB?

Smita Kapse

Smita Kapse

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

185 Views

You can achieve pagination with the help of limit() and skip() in MongoDB.To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.paginationDemo.insertOne({"CustomerName":"Chris", "CustomerAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c949de44cf1f7a64fa4df52") } > ... Read More

Advertisements