It was Sunday on Jan 1, 2006. What was the


  1. It was Sunday on Jan 1, 2006. What was the day of the week Jan 1, 2010?
    or
    If it was sunday on jan 1st 2006. What was the day of the week Jan 1, 2010?
  1. A. Sunday
  2. B. Saturday
  3. C. Friday
  4. D. Wednesday

  1. Answer & Explanation: C

    ⇒  31st Dec, 2005 was Saturday.  [ Given : it was Sunday on January 1st 2006 ]
    No. of odd days from the year 2006 to the year 2009 = (1 + 1 + 2 + 1) = 5 days.
    ⇒  On 31st Dec 2009, it was Thursday.
    Thus, on January 1st 2010 it is Friday.

  1. Related Question:

  1. Today is Monday. After 61 days, it will be:
  1. A. Wednesday
  2. B. Saturday
  3. C. Tuesday
  4. D. Thursday
  1. Answer : B ( Saturday )

  1. What was the day of the week on 28th May, 2006?
  1. A. Thursday
  2. B. Friday
  3. C. Saturday
  4. D. Sunday
  1. Answer : D ( Sunday )

  1. What day of the week was 31st July, 1993?
  1. A. Monday
  2. B. Sunday
  3. C. Saturday
  4. D. Tuesday
  1. Answer : C ( Saturday )

  1. The last day of a century cannot be
  1. A. Monday
  2. B. Wednesday
  3. C. Tuesday
  4. D. Friday
  1. Answer : C ( Tuesday )

  1. How many days are there in x weeks x days?
  1. A. 7x²
  2. B. 8x
  3. C. 14x
  4. D. 7

  1. Answer : B ( 8x )

MongoDB Aggregate Query and Aggregation Pipeline Operator

mongoDB Aggregate Query with Example

MongoDB Aggregation Pipeline Operator

We will perform all the mongoDB Aggregation Operator on studentInfo DB. Create studentInfo Database in MongoDB server. Use the below code for creating the DB.

  

Insert Some Document in student collection where we can apply the MongoDB Collection Methods to explore further usage. Inserting five document in Student Collection. Below is the document list present in student collection.

{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf54"),
        "id" : 1,
        "name" : "M Kumar",
        "dob" : "2003-04-07",
        "marks" : 54,
        "created_at" : "2017-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf55"),
        "id" : 2,
        "name" : "MOHAMMED ISHAQ  H",
        "dob" : "2002-06-14",
        "marks" : 67,
        "created_at" : "2016-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf56"),
        "id" : 3,
        "name" : "ANBUSELVAM S",
        "dob" : "2004-06-18",
        "marks" : 87,
        "created_at" : "2019-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf57"),
        "id" : 4,
        "name" : "MARTINPRIYADOSS J",
        "dob" : "2004-03-08",
        "marks" : 43,
        "created_at" : "2012-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebf58376803d36568082c60"),
        "id" : 5,
        "name" : "JAGAN J",
        "dob" : "2003-04-10",
        "marks" : 98,
        "created_at" : "2012-11-13 23:33:42"
}

Aggregation Pipeline Stages


MongoDb Aggregation purpose is to process the data to get the computed Result. For executing that we use db.collectionName.aggregate() method.

Aggregation Syntax is     db.collectionName.aggregate( [ { <stage> }, ... ] )

$toLower() Aggregate Function


$toLower function in mongoDB convert the given strings in lower case and return the result. Below is the code for your Reference purpose.
db.student.aggregate([{$project :{name :{$toLower:"$name"}}}])
As above code will convert the document name field in lower case. Below is the output.
{ "_id" : ObjectId("5ebeaafd50845b5c0ea8bf54"), "name" : "m kumar" }
{ "_id" : ObjectId("5ebeaafd50845b5c0ea8bf55"), "name" : "mohammed ishaq  h" }
{ "_id" : ObjectId("5ebeaafd50845b5c0ea8bf56"), "name" : "anbuselvam s" }
{ "_id" : ObjectId("5ebeaafd50845b5c0ea8bf57"), "name" : "martinpriyadoss j" }
{ "_id" : ObjectId("5ebf58376803d36568082c60"), "name" : "jagan j" }


$toUpper() Aggregate Function


















Telangana GK Question, quiz in English and Telugu

Telangana gk





  1. Total number of states that shares borders with Telangana is
    1. A. 4       Correct Answer
    2. B. 5      
    3. C. 6      
    4. D. 8      
  2.  

    What was the name of the military operation that conducted to merge Hyderabad with India
    1. A. Operation Thunder     
    2. B. Operation Hyderabad      
    3. C. Operation Polo        Correct Answer
    4. D. Operation Strom      
  3.  

    Who is appointed as the "brand ambassador" of Telangana.
    1. A. Mohammad Azharuddin     
    2. B. Saina Nehwal      
    3. C. V. V. S. Laxman      
    4. D. Sania Mirza        Correct Answer
  4.  

    Total number of districts in Telangana
    1. A. 7     
    2. B. 8      
    3. C. 10        Correct Answer
    4. D. 14      
  5.  

    Who was the last Nizam of Hyderabad
    1. A. Mir Osman Ali Khan       Correct Answer
    2. B. Mir Akbar Ali Khan      
    3. C. Mir Mahbub Ali Khan      
    4. D. Mir Nizam Ali Khan      
  6.  

    Bathukamma is a part of which festival
    1. A. Dasara       Correct Answer
    2. B. Ugadi      
    3. C. Sankranti      
    4. D. Mahashivaratri      
  7.  

    In which year the Charminar was built
    1. A. 1519     
    2. B. 1538      
    3. C. 1564      
    4. D. 1591        Correct Answer
  8.  

    The Telangana state was formed on _____ june 2014
    1. A. 2nd       Correct Answer
    2. B. 4th      
    3. C. 9th      
    4. D. 15th      
  9.  

    Who was the founder of the Hyderabad city and Charminar
    1. A. Ibrahim Quli Qutb Shah     
    2. B. Muhammad Quli Qutb Shah        Correct Answer
    3. C. Abdullah Qutb Shah      
    4. D. Abul Hasan Qutb Shah      
  10.  

    Which one is the largest district by area wise in Telangana
    1. A. Adilabad     
    2. B. Nizamabad      
    3. C. Khammam      
    4. D. Bhadradri        Correct Answer
  11.  

    Rudrama Devi belongs to which dynasty
    1. A. Vijayanagara Empire     
    2. B. Pallava dynasty      
    3. C. Reddy dynasty      
    4. D. Kakatiya dynasty        Correct Answer
  12.  

    What is the literacy rate in Telangana
    1. A. 59.11 %     
    2. B. 66.46 %        Correct Answer
    3. C. 69.26 %      
    4. D. 72.08 %      
  13.  

    The Bhadrakali Lake is located in which district
    1. A. Karimnagar     
    2. B. Warangal        Correct Answer
    3. C. Nizamabad      
    4. D. Nalgonda      
  14.  

    Total number of National Park in Telangana
    1. A. 2     
    2. B. 3        Correct Answer
    3. C. 4      
    4. D. 6      
  15.  

    In which year Hyderabad was officially declared as the capital of Nizams
    1. A. 1702     
    2. B. 1715      
    3. C. 1769        Correct Answer
    4. D. 1798 

Chandan Buys Some Sugar at Rs. 15 per kg

  1.  
    Chandan buys some sugar at Rs. 15 per kg. He mixes it with sugar having price Rs. 18 per kg. The final mixture becomes worth Rs. 16 per kg. What is the ratio of quantities of type 1 sugar to type 2 sugar?
  1. A. 2:1
  2. B. 1:2
  3. C. 5:6
  4. D. 6:5
  1. Answer & Explanation:
    2:1

  1. Related Question:

  1. Rohit buys some rice at Rs. 10.40 per kg. He mixes it with some rice having price Rs. 8.8 per kg. The final mixture becomes 15kg in weight and with total worth Rs. 146.40. What is the quantity of rice priced at Rs. 8.8 per kg?
  1. A. 9 kg
  2. B. 10 kg
  3. C. 5 kg
  4. D. 6 kg
  1. Answer : D ( 6 kg )

  1. How many kilogram of sugar costing Rs. 9 per kg must be mixed with 27 kg of sugar costing Rs. 7 per kg so that there may be a gain of 10% by selling the mixture at Rs. 9.24 per kg?
  1. A. 36 kg
  2. B. 42 kg
  3. C. 54 kg
  4. D. 63 kg
  1. Answer : D ( 63 kg )

  1. Two solutions of milk and water are kept in two vessels A and B. The ratio of quantity of milk in vessels A and B is 4:5 while the ratio of quantity of water in vessels A and B is 8:9. It is known that the concentration of milk in one of these vessels in between 60% and 80%. What could be the concentration of milk in the other vessel?
  1. A. 55%
  2. B. 65%
  3. C. 75%
  4. D. 85%
  1. Answer : C ( 75% )

  1. In a mixture of 90 L the ratio of acid and water is 2 : 1. If the ratio of acid and water is to be 1 : 2, then the amount of water (in litres) to be added to the mixture is?
  1. A. 20L
  2. B. 40L
  3. C. 90L
  4. D. 100L
  1. Answer : C ( 90L )

  1. What per cent of the water should be added to pure milk so that even if selling price decreases the profit percentage is not affected?
  1. A. 10%
  2. B. 30%
  3. C. 20%
  4. D. 25%

  1. Answer : D ( 25% )

Mongodb Cursor Methods and Example

Cursor method in mongoDB

MongoDB Cursor Method with Example


Cursor in MongoDB is defined as a returned Collection Document when find method execution happens. Cursor is like array of a pointer which point specific Index. 

We will perform all the mongoDB Shell Cursor methods on studentInfo DB. Create studentInfo Database in MongoDB server. Use the below code for creating the DB.

  

Using db.createCollection() method, create collection in database. Command to create studnet collection in studentInfo Database is below 


Insert Some Document in student collection where we can apply the MongoDB Collection Methods to explore further usage. I am Inserting five document in Student Collection. Inserted document in student Collection. Below is the document list present in student collection.
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf54"),
        "id" : 1,
        "name" : "M Kumar",
        "dob" : "2003-04-07",
        "marks" : 54,
        "created_at" : "2017-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf55"),
        "id" : 2,
        "name" : "MOHAMMED ISHAQ  H",
        "dob" : "2002-06-14",
        "marks" : 67,
        "created_at" : "2016-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf56"),
        "id" : 3,
        "name" : "ANBUSELVAM S",
        "dob" : "2004-06-18",
        "marks" : 87,
        "created_at" : "2019-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf57"),
        "id" : 4,
        "name" : "MARTINPRIYADOSS J",
        "dob" : "2004-03-08",
        "marks" : 43,
        "created_at" : "2012-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebf58376803d36568082c60"),
        "id" : 5,
        "name" : "JAGAN J",
        "dob" : "2003-04-10",
        "marks" : 98,
        "created_at" : "2012-11-13 23:33:42"
}

MongoDB Cursor Count() Method



Count() Method will return the document count in specified MongoDB collection. O/P of the above query is 5 as per the above document inserted in it.

db.student.find({marks :{$lt : 70}}).count()

Output of the above query will be 3.

MongoDB Cursor Limit() Method

limit() Method in MongoDB will restrict the document count output while we fetch using find method.. 

db.student.find({$or :[{id :{$lt : 2}},{marks :{$gt:80}}] }).pretty()
O/P :
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf54"),
        "id" : 1,
        "name" : "M Kumar",
        "dob" : "2003-04-07",
        "marks" : 54,
        "created_at" : "2017-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf56"),
        "id" : 3,
        "name" : "ANBUSELVAM S",
        "dob" : "2004-06-18",
        "marks" : 87,
        "created_at" : "2019-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebf58376803d36568082c60"),
        "id" : 5,
        "name" : "JAGAN J",
        "dob" : "2003-04-10",
        "marks" : 98,
        "created_at" : "2012-11-13 23:33:42"
}
db.student.find({$or :[{id :{$lt : 2}},{marks :{$gt:80}}] }).limit(2).pretty()

mongoDB cursor Limit method
Output :
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf54"),
        "id" : 1,
        "name" : "M Kumar",
        "dob" : "2003-04-07",
        "marks" : 54,
        "created_at" : "2017-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf56"),
        "id" : 3,
        "name" : "ANBUSELVAM S",
        "dob" : "2004-06-18",
        "marks" : 87,
        "created_at" : "2019-11-13 23:33:42"
}

MongoDB Cursor Pretty() Method 


Cursor Pretty() method will output the fetched collection document in readable format. Without pretty() method all the Collection document will come row by row. Below is the example with and without pretty() method

db.student.find({marks : {$gt : 60}})

Without MongoDB Pretty Method

db.student.find({marks : {$gt : 70}}).pretty()
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf56"),
        "id" : 3,
        "name" : "ANBUSELVAM S",
        "dob" : "2004-06-18",
        "marks" : 87,
        "created_at" : "2019-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebf58376803d36568082c60"),
        "id" : 5,
        "name" : "JAGAN J",
        "dob" : "2003-04-10",
        "marks" : 98,
        "created_at" : "2012-11-13 23:33:42"
}

MongoDB Cursor Sort() Method


Cursor sort() Method in mongoDB hep us to arrange the Specified collection document in sorting order of Ascending or Descending Order. Here Sorting In ascending order is represented by 1 and for descending order it is -1. Below is the Example code , how to use sort() method in MongoDB.

db.student.find({marks :{$lte : 90 }}).sort({marks:1}).pretty()

Cursor Sort() in Ascending Order in MongoDB

Output of the above sort() method code is below as a result. Here in the above code we arranged the document in ascending order based on the mark column.
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf57"),
        "id" : 4,
        "name" : "MARTINPRIYADOSS J",
        "dob" : "2004-03-08",
        "marks" : 43,
        "created_at" : "2012-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf54"),
        "id" : 1,
        "name" : "M Kumar",
        "dob" : "2003-04-07",
        "marks" : 54,
        "created_at" : "2017-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf55"),
        "id" : 2,
        "name" : "MOHAMMED ISHAQ  H",
        "dob" : "2002-06-14",
        "marks" : 67,
        "created_at" : "2016-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf56"),
        "id" : 3,
        "name" : "ANBUSELVAM S",
        "dob" : "2004-06-18",
        "marks" : 87,
        "created_at" : "2019-11-13 23:33:42"
}

Sort() in MongoDB in Descending Order

db.student.find({marks : {$lte : 90}},{name:1,marks:1,_id:1}).sort({name:-1}).pretty()
Above command will arrange the document collection in descending order based on the name. Here -1 is for descending order, name is the document field.
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf55"),
        "name" : "MOHAMMED ISHAQ  H",
        "marks" : 67
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf57"),
        "name" : "MARTINPRIYADOSS J",
        "marks" : 43
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf54"),
        "name" : "M Kumar",
        "marks" : 54
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf56"),
        "name" : "ANBUSELVAM S",
        "marks" : 87
}

Cursor Skip() method in mongoDB


db.student.find({marks:{$lt : 80}},{name:1,marks:1,_id:0}).sort({name:1}).pretty()

This above query will give the output which is below and without skip() method.

{ "name" : "M Kumar", "marks" : 54 }
{ "name" : "MARTINPRIYADOSS J", "marks" : 43 }
{ "name" : "MOHAMMED ISHAQ  H", "marks" : 67 }

Now we will apply limit and get the document.

db.student.find({marks:{$lt : 80}},{name:1,marks:1,_id:0}).sort({name:1}).limit(1).pretty()

Output of the above query will be

{ "name" : "M Kumar", "marks" : 54 }

see the output of both the query, first query have given three document as a output and the second query have given one document because limit is set on the query.

Now we will apply skip() mongoDB Method with limit then we will understand the difference.

db.student.find({marks:{$lt : 80}},{name:1,marks:1,_id:0}).sort({name:1}).limit(1).skip(1)

Output of the above query is below. In the above query limit is set the first record will be skipped and the second record will be taken if available.

{ "name" : "MARTINPRIYADOSS J", "marks" : 43 }

Cursor toArray() Method in MongoDB

toArray() method return all the collection document as an array from the cursor. If we use toArray() method, it will iterate the cursor and load all the data in RAM. In simple word It return an Array of Document.

toArray() Mongo Method Create the json array using all the cursor Document specified which is the easiest way to pass the result to Application.

db.student.find().limit(2).toArray()
.
toArray() method In MongoDB

See the above MongoDB Query where toArray() method have return the document as a array. If you execute the mongo query without toArray() method it will just return the document collection. Below is the output of below query.

db.student.find().limit(2).pretty()

{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf54"),
        "id" : 1,
        "name" : "M Kumar",
        "dob" : "2003-04-07",
        "marks" : 54,
        "created_at" : "2017-11-13 23:33:42"
}
{
        "_id" : ObjectId("5ebeaafd50845b5c0ea8bf55"),
        "id" : 2,
        "name" : "MOHAMMED ISHAQ  H",
        "dob" : "2002-06-14",
        "marks" : 67,
        "created_at" : "2016-11-13 23:33:42"
}



Our Feature Post

There is a tree between houses of A and B If the tree leans on As House

    There is a tree between houses of A and B. If the tree There is a tree between houses of A and B. If the tree leans on A’s House, the t...

Our Popular Post