Work with Push in MongoDB

AmitDiwan
Updated on 30-Jun-2020 07:51:10

224 Views

Let us create a collection with documents −> db.demo738.insertOne({Subjects:["C", "C++"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead696557bb72a10bcf0661") } > db.demo738.insertOne({Subjects:["MySQL", "PL/SQL"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead696657bb72a10bcf0662") }Display all documents from a collection with the help of find() method −> db.demo738.find();This will produce the following output −{ "_id" : ObjectId("5ead696557bb72a10bcf0661"), "Subjects" : [ "C", "C++" ] } { "_id" : ObjectId("5ead696657bb72a10bcf0662"), "Subjects" : [ "MySQL", "PL/SQL" ] }Following is the query to push −>db.demo738.update({_id:ObjectId("5ead696657bb72a10bcf0662")}, {$push:{"Subjects":"MongoDB"}}); WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })Display all documents from a collection with the help of ... Read More

Show Background Image Only Once with CSS

Giri Raju
Updated on 30-Jun-2020 07:50:30

804 Views

Use the background-repeat property to display the background image only once. You can try to run the following code to implement the background-repeat property −ExampleLive Demo                    body {             background-image: url("https://www.tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg");             background-repeat: no-repeat;          }                     Background Image    

Order by Timestamp in Descending Order in MongoDB

AmitDiwan
Updated on 30-Jun-2020 07:49:10

2K+ Views

To order by timestamp, use sort() in MongoDB. Let us create a collection with documents −> db.demo737.insertOne({"timestamp" : new ISODate("2020-04-01" )}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead682157bb72a10bcf065c") } > db.demo737.insertOne({"timestamp" : new ISODate("2020-10-31" )}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead682757bb72a10bcf065d") } > db.demo737.insertOne({"timestamp" : new ISODate("2020-05-02" )}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead682a57bb72a10bcf065e") }Display all documents from a collection with the help of find() method −> db.demo737.find();This will produce the following output −{ "_id" : ObjectId("5ead682157bb72a10bcf065c"), "timestamp" : ISODate("2020-04-01T00:00:00Z") } { "_id" : ObjectId("5ead682757bb72a10bcf065d"), "timestamp" : ISODate("2020-10-31T00:00:00Z") } { "_id" : ... Read More

Set Responsive Font Size using CSS

radhakrishna
Updated on 30-Jun-2020 07:48:43

334 Views

To set the responsive font size, use the ‘viewport width’ and set it to ‘vw’ unit. You can try to run the following code to use ‘vw’ unit −ExampleLive Demo                    h1 {             font-size:8vw;          }                     This is demo heading       This is demo text.    

Filter Query on Array of Embedded Document with MongoDB

AmitDiwan
Updated on 30-Jun-2020 07:47:50

348 Views

For this, use aggregate() in MongoDB. Let us create a collection with documents −> db.demo736.insertOne( ...    { ...       "_id": "101", ...       "details1": [ ...          { ...             "details2": [ ...                { ...                   "details3": { ...                      "Name": "John" ...                   } ...                } ... ... Read More

Role of CSS :hover Selector

varma
Updated on 30-Jun-2020 07:46:59

329 Views

Use the CSS :hover selector to style links on mouse over with CSS. You can try to run the following code to implement the :hover selector −ExampleLive Demo                    a:hover {             background-color: orange;          }                     Qries       Keep the mouse cursor on the above link and see the effect.    

Change Root Username in MySQL

George John
Updated on 30-Jun-2020 07:45:45

3K+ Views

To change the root username in MySQL, you need to use UPDATE and SET command. The syntax is as follows −UPDATE user set user = ’yourNewUserName’ WHERE user = ’root’;To understand the above syntax, let us switch the database to MySQL using USE command.The query is as follows to switch the database.mysql> use mysql; Database changedNow list all the users from MySQL.user table. The query is as follows −mysql> select user from MySQL.user;The following is the output −+------------------+ | user             | +------------------+ | Manish           | | User2     ... Read More

Style the Focused Element in CSS

Ankith Reddy
Updated on 30-Jun-2020 07:45:24

129 Views

To select the element that has focus, use the: focus selector. You can try to run the following code to implement the: focus selector −Example                    input:focus {             background-color: green;          }                              Subject          Student:          Age:

Using MongoDB updateOne and insertOne

AmitDiwan
Updated on 30-Jun-2020 07:44:44

1K+ Views

MongoDB insertOne() inserts a document into a collection, whereas updateOne() update a single document in a collection based on a query filter.Let us create a collection with documents −> db.demo735.insertOne({id:1, Name:"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead51b657bb72a10bcf0652") } > db.demo735.insertOne({id:1, Name:"David"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead51bb57bb72a10bcf0653") } > db.demo735.insertOne({id:1, Name:"Bob"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead51be57bb72a10bcf0654") } > db.demo735.insertOne({id:1, Name:"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead51c757bb72a10bcf0655") }Display all documents from a collection with the help of find() method −> db.demo735.find();This will produce the following output −{ "_id" ... Read More

Role of CSS :focus Selector

Chandu yadav
Updated on 30-Jun-2020 07:44:17

170 Views

Use the :focus selector to select the element that has focus. You can try to run the following code to implement the :focus selectorExample                    input:focus {             background-color: green;          }                              Subject          Student:          Age:                    

Advertisements