Use Geolocation Coordinates in HTML5

Nishtha Thakur
Updated on 14-May-2020 10:46:51

433 Views

HTML5 Geolocation API lets you share your location with your favorite websites. A Javascript can capture your latitude and longitude and can be sent to backend web server and do fancy location-aware things like finding local businesses or showing your location on a map. The geolocation coordinates specifies the geographic location of the device.Geolocation methods getCurrentPosition() and getPositionUsingMethodName() specify the callback method that retrieves the location information. These methods are called asynchronously to an object Position which stores the complete location information.The Position object specifies the current geographic location of the device. The location is expressed as a set of ... Read More

Use the formmethod Attribute in HTML

Nancy Den
Updated on 14-May-2020 10:22:35

203 Views

The formmethod attribute is used to define the HTTP technique for sending form information. This method is usedwith input type submit a picture. It overrides the method attribute of HTML forms.ExampleYou can try to run the following code to learn how to use the formmethod attribute in HTML.           HTML formmethod attribute                        Student Name          Student Subject                              

MongoDB Query for Counting Distinct Values Across All Documents

AmitDiwan
Updated on 14-May-2020 10:22:06

470 Views

For this, use aggregate() in MongoDB. Let us create a collection with documents −> db.demo718.insertOne( ...    { ...       "id":101, ...       "details": ...       { ...          "OtherDetails": ["Chris", "Mike", "Sam"], "GroupName": ["Group-1"], "Info": [] ...       } ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5eaae25843417811278f5880") } > db.demo718.insertOne( ...    { ...       "id":102, ...       "details": ...       { ...          "OtherDetails": ["Chris", "David"], "GroupName": ["Group-1"], "Info": [] ...   ... Read More

Aggregate and Group by Date in Nested Documents

AmitDiwan
Updated on 14-May-2020 10:20:20

290 Views

For aggregation, use aggregate() in MongoDB. Group the dates with $group. Let us create a collection with documents −> db.demo717.insertOne( ...    { ...       "shippingdetails": ...       [ ...          { ...             duedate:"2020-04-29 22:33:04", ...          }, ...          { ...             duedate:"2020-03-29 22:33:04", ...          }, ...          { ...             duedate:"2020-04-29 22:33:04", ...          }, ...       ... Read More

Creating Hierarchical JSON in MongoDB

AmitDiwan
Updated on 14-May-2020 10:16:43

247 Views

Use the following syntax to create hierarchical JSON in MongoDB −db.demo716.insertOne(    {       yourFieldName1,       yourFieldName2,       .       .       N,       "fieldName": {          yourFieldName1,          yourFieldName2,          .          .          N,          "fieldname":          [             {                yourFieldName1,                yourFieldName2,         ... Read More

Removing an Object in a Child Collection in MongoDB

AmitDiwan
Updated on 14-May-2020 10:12:12

650 Views

To remove an object in a child collection, use $pull in MongoDB. Let us create a collection with documents −> db.demo715.insertOne({ ...    _id:1, ...    details : ...    [ ...       { 'id' : '101', ...       'Information' : [ ...          { ...             'studentid' : '102', ...             "Name":"Bob" ...          }, ...          { ...             'studentid' : '103', ...             "Name":"Chris" ... Read More

MongoDB Compound Conditions to Fetch Documents

AmitDiwan
Updated on 14-May-2020 10:10:06

150 Views

Let us create a collection with documents −> db.demo714.insertOne({FirstName:"Chris", LastName:"Brown"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea9a2da85324c2c98cc4c2b") } > db.demo714.insertOne({FirstName:"Adam", LastName:"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea9a2e585324c2c98cc4c2c") } > db.demo714.insertOne({FirstName:"David", LastName:"Miller"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea9a2ed85324c2c98cc4c2d") } > db.demo714.insertOne({FirstName:"John", LastName:"Doe"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea9a2f785324c2c98cc4c2e") }Display all documents from a collection with the help of find() method −> db.demo714.find();This will produce the following output −{ "_id" : ObjectId("5ea9a2da85324c2c98cc4c2b"), "FirstName" : "Chris", "LastName" : "Brown" } { "_id" : ObjectId("5ea9a2e585324c2c98cc4c2c"), "FirstName" : "Adam", "LastName" : "Smith" } { ... Read More

Update Tag Records in MongoDB Quickly

AmitDiwan
Updated on 14-May-2020 10:08:31

120 Views

Use $ along with update command to update tag records. Let us create a collection with documents −> db.demo713.insertOne( ...    { ...       tags: ...       [ ...          { ...             id:101, ...             Name:"Tag-1" ...          }, ...          { ...             id:102, ...             Name:"Tag-3" ...          }, ...          { ...           ... Read More

Add New Field to All Documents in a MongoDB Collection

AmitDiwan
Updated on 14-May-2020 10:06:37

563 Views

To add a new field, use $addFields in MongoDB. Let us create a collection with documents −> db.demo712.insertOne({"Name":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea85f675d33e20ed1097b82") } > db.demo712.insertOne({"Name":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea85f6a5d33e20ed1097b83") } > db.demo712.insertOne({"Name":"Bob"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea85f6e5d33e20ed1097b84") }Display all documents from a collection with the help of find() method −> db.demo712.find();This will produce the following output −{ "_id" : ObjectId("5ea85f675d33e20ed1097b82"), "Name" : "John" } { "_id" : ObjectId("5ea85f6a5d33e20ed1097b83"), "Name" : "Chris" } { "_id" : ObjectId("5ea85f6e5d33e20ed1097b84"), "Name" : "Bob" }Following is the query to add a ... Read More

MongoDB Query to Get Documents with Multiple Conditions Set in OR

AmitDiwan
Updated on 14-May-2020 10:03:43

2K+ Views

Let us create a collection with documents −> db.demo711.insertOne({Name:"John", "Marks":75, Age:21, status:"Active"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea85c215d33e20ed1097b7e") } > db.demo711.insertOne({Name:"Chris", "Marks":55, Age:22, status:"Active"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea85c2c5d33e20ed1097b7f") } > db.demo711.insertOne({Name:"Bob", "Marks":45, Age:20, status:"Inactive"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea85c3e5d33e20ed1097b80") } > db.demo711.insertOne({Name:"David", "Marks":85, Age:23, status:"Active"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ea85c775d33e20ed1097b81") }Display all documents from a collection with the help of find() method −> db.demo711.find();This will produce the following output −{ "_id" : ObjectId("5ea85c215d33e20ed1097b7e"), "Name" : "John", "Marks" : 75, "Age" : 21, "status" : ... Read More

Advertisements