O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a document

To insert a document, first we specify the collection name and pass the JSON document by calling the insert method as the following syntax:

> db.collection_name.insert(JSON_Object)

Let's insert the first team to our teams collection:

> db.teams.insert({"code": "PER",   ... "name": "Peru",   ... "ranking": 11,   ... "captain": "Paolo Guerreo",   ... "Trainer": "Ricardo Gareca",   ... "confederation": "Conmebol"})WriteResult({ "nInserted" : 1 })        
The three dots at the beginning of the lines refer to new lines or the Enter key.

If the insertion was executed correctly, you should receive the writeResult response that contains the number of documents inserted into its nInserted property.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required