Chandu yadav has Published 1091 Articles

Building Multiple Indexes at once in MongoDB?

Chandu yadav

Chandu yadav

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

2K+ Views

In order to build multiple indexes at once, you need to use createIndexes() and pass multiple keys into an array. Following is the query for building multiple indexes at once.>db.multipleIndexesDemo.createIndexes([{"First":1}, {"Second":1}, {"Third":1}, {"Fourth":1}, {"Fifth":1}]);This will produce the following output{    "createdCollectionAutomatically" : true,    "numIndexesBefore" : 1,    "numIndexesAfter" : ... Read More

How to find capital letters with Regex in MySQL?

Chandu yadav

Chandu yadav

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

509 Views

You can use REGEXP BINARY for thisselect *from yourTableName where yourColumnName REGEXP BINARY '[A-Z]{2}';Let us first create a tablemysql> create table FindCapitalLettrsDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentFirstName varchar(20)    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records ... Read More

Get the average of an entire field using the aggregation framework in MongoDB?

Chandu yadav

Chandu yadav

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

144 Views

You can use aggregate() method for this. Let us first create a collection with documents> db.averageAggregationDemo.insertOne({"PlayerGameScore":45}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ed66bd628fa4220163b95") } > db.averageAggregationDemo.insertOne({"PlayerGameScore":55}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ed671d628fa4220163b96") } > db.averageAggregationDemo.insertOne({"PlayerGameScore":65}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ed676d628fa4220163b97") } ... Read More

What is a pageContext Object in JSP?

Chandu yadav

Chandu yadav

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

1K+ Views

The pageContext object is an instance of a javax.servlet.jsp.PageContext object. The pageContext object is used to represent the entire JSP page.This object is intended as a means to access information about the page while avoiding most of the implementation details.This object stores references to the request and response objects for ... Read More

Query MongoDB for a datetime value less than NOW?

Chandu yadav

Chandu yadav

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

710 Views

You can use $lte operator along with new Date() for this. Let us first create a collection with documents>db.dateTimeValueLessThanNowDemo.insertOne({"CustomerName":"Larry", "CustomerProductName":"Product-1", "ArrivalDate":new ISODate("2017-01-31")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca1e8ab66324ffac2a7dc59") } >db.dateTimeValueLessThanNowDemo.insertOne({"CustomerName":"Mike", "CustomerProductName":"Product-2", "ArrivalDate":new ISODate("2019-04-01")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca1e8c166324ffac2a7dc5a") } >db.dateTimeValueLessThanNowDemo.insertOne({"CustomerName":"Chris", "CustomerProductName":"Product-3", "ArrivalDate":new ISODate("2019-03-31")}); ... Read More

8086 program to subtract two 16 bit BCD numbers

Chandu yadav

Chandu yadav

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

1K+ Views

In this program we will see how to subtract two 16-bit BCD numbers.Problem StatementWrite 8086 Assembly language program to subtract two 16-bit BCD numbers stored in memory offset 500H – 501H and 502H – 503H.DiscussionHere we are adding the 16-bit data byte by byte. At first we are subtracting lower ... Read More

What is a page object in JSP?

Chandu yadav

Chandu yadav

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

427 Views

This object is an actual reference to the instance of the page. It can be thought of as an object that represents the entire JSP page.The page object is really a direct synonym for the this object.

Set Ennead value in JavaTuples

Chandu yadav

Chandu yadav

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

112 Views

To set Ennead value in Java, you need to use the setAtX() method. Here, X represents the index wherein you need to set the value i.e. for index 1, use setAt1() method. Set the value as the parameter value of the method.Let us first see what we need to work ... Read More

Using find() to search for nested keys in MongoDB?

Chandu yadav

Chandu yadav

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

807 Views

For find() to search for nested keys in MongoDB, you can use dot(.) notation. Following is the syntaxdb.yourCollectionName.find({"yourOuterFieldName.yourInnerFieldName":"yourValue"}).pretty();Let us first create a collection with documents:>db.searchForNestedKeysDemo.insertOne({"ClientName":"Larry", "ClientAge":28, "ClientExtra Details":{"isEducated":true, "CountryName":"US"}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca20e8b66324ffac2a7dc64") } >db.searchForNestedKeysDemo.insertOne({"ClientName":"Chris", "ClientAge":29, "ClientExtra Details":{"isEducated":false, "CountryName":"UK"}}); {    "acknowledged" : true,   ... Read More

Is there a way to convert Integer field into Varchar without losing data in MySQL?

Chandu yadav

Chandu yadav

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

1K+ Views

You can use ALTER command to convert Integer into Varchar. Let us first create a tablemysql> create table DemoTable (    UserId int,    UserFirstName varchar(20),    UserLastName varchar(20),    UserAge int ); Query OK, 0 rows affected (0.73 sec)Now check the description of table using DESC command:mysql> desc DemoTable;This ... Read More

Advertisements