Page 529 - Computer_Science_F5
P. 529

Computer Science  (a)  Insert a single document into a collection: A query example that insert a
                  single document into a collection is as presented in Figure 8.28.





          FOR ONLINE READING ONLY


                                Figure 8.28: Inserting a document in MongoDB
               (b) Insert multiple documents into a collection: A query example that inserts
                  multiple documents into a collection is presented as shown in Figure 8.29:









                             Figure 8.29: Inserting multiple documents in MongoDB
               (c)  Find document from a collection: To verify that the documents you entered
                  are there in the collection run the command “db.collection_name.find ()”.
                  The collection name can be replaced by the name of the database/collection
                  you are referring to as shown in Figure 8.30.



































                         Figure 8.30: Finding a document from a collection in MongoDB



                                                 520
                                                                for Advanced Secondary Schools



     Computer Science Form 5.indd   520                                                     23/07/2024   12:35
   524   525   526   527   528   529   530   531   532   533   534