Cover Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
Title Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Copyright Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
Dedication Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
About the Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
The four applications covered in this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
Errata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
1. Client and Server-Side Concepts and Introduction to MongoDB Drivers . . . . . . . . .34
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Client and server-side concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Client and server-side DB concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Introduction to MongoDB drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
MongoDB drivers for programming languages (PHP, JavaScript, and Python) . .41
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
2. Data Addition Using MongoDB Compass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
About MongoDB Compass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Launching MongoDB Compass and connecting to MongoDB server using MongoDB Compass .44
Creating a MongoDB database and collection using MongoDB Compass . . . . . . . . .46
Data addition using MongoDB Compass (creating some documents in our MongoDB collection) .48
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
3. Starting Up Programming with MongoDB and PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Using PHP with MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Installing WAMP server on Windows operating system . . . . . . . . . . . . . . . . .59
Installation steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Programming with PHP and MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76
Starting MongoDB server from Windows service manager . . . . . . . . . . . . . . .76
Example 1—connecting to MongoDB Server using PHP . . . . . . . . . . . . . . . . . . .79
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
Example 2—fetching MongoDB Documents using PHP . . . . . . . . . . . . . . . . . . . . .79
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
4. Starting Up Programming with MongoDB and JavaScript (Node.js) . . . . . . . . . . . . . . .82
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
Using JavaScript (Node.js) with MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Installing Node.js on Windows operating system . . . . . . . . . . . . . . . . . . . . .83
Installation steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Step 2—install Node.js on your Windows machine. . . . . . . . . . . . . . . . . . . . .85
Step 3—post-installation steps and verifying Node.js on your Windows machine .90
Step 4—installing the MongoDB driver for Node.js using NPM . . . . . . . . .92
Connecting and working with Node.js and MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . .96
Example 1—connecting to MongoDB server using Node.js . . . . . . . . . . . . . . .96
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
Example 2—fetching MongoDB documents using Node.js . . . . . . . . . . . . . . . . .98
Code 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100
5. Starting Up Programming with MongoDB and React Native . . . . . . . . . . . . . . . . . . . . . .101
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
Introduction to React Native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
Pre-development steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
Step 1—check Node.js and NPM on your system . . . . . . . . . . . . . . . . . . . . . . .103
Step 2—creating a project folder in your system . . . . . . . . . . . . . . . . . . .105
Step 3—installing Android Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
Step 4—installing Android SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112
Step 5—setting up the environment variables . . . . . . . . . . . . . . . . . . . . . . .116
Step 6—installing Expo CLI using NPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
Step 7—creating our mobile App using Expo and Expo CLI . . . . . . . . . . . .124
Step 8—running our mobile App using Expo and Expo CLI . . . . . . . . . . . . .126
Step 9—opening and viewing an app in mobile device using Expo app .130
Step 10—opening and viewing app in Android Emulator . . . . . . . . . . . . . . .140
Programming with React Native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
Example 1—changing the text in our mobile App . . . . . . . . . . . . . . . . . . . . .148
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148
Code 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149
Example 2—adding logo image in our mobile App . . . . . . . . . . . . . . . . . . . . .153
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153
A brief introduction to programming with React Native and MongoDB . . . . . . .155
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157
6. Starting Up Programming with MongoDB and Python . . . . . . . . . . . . . . . . . . . . . . . . . . . .158
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158
Using Python with MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159
Installing Python on Windows operating system . . . . . . . . . . . . . . . . . . . . .159
Installation steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159
Step 1—download Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159
Step 2—install Python on your Windows Machine . . . . . . . . . . . . . . .161
Step 3—post-installation steps and verifying Python on your Windows Machine .166
Step 4—installing MongoDB driver for Python using Python Package Index (PyPI) .168
Programming with Python and MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170
Example 1—connecting to MongoDB server using Python . . . . . . . . . . . . . . .170
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
Example 2—fetching MongoDB documents using Python . . . . . . . . . . . . . . . . .172
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173
7. Full-Stack Development Using MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
Introduction to full-stack development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
Frontend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
Frontend technologies and stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .176
Native mobile apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177
Hybrid mobile apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
Backend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
Back-end technologies and stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179
Full-stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179
Full-stack development and technologies . . . . . . . . . . . . . . . . . . . . . . . . . . .180
Full-stack developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183
8. MongoDB Step by Step Practical Application Development Using PHP . . . . . . . . . . .184
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185
Overview of our Web application developed using PHP and MongoDB . . . . . . . . .185
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186
Final application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186
Pre-development steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188
Developing our application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204
Code 1—our basic HTML structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205
Code 2—our header.php file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
Code 3—our footer.php file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
Code 1—our header.php file (updated) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
Code 1—our index.php file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207
Code 1—our styles.css file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209
Code 2—our scripts.js file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209
Backend catalog dashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210
Code 1—our index.php file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Code 2—our styles.css file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Adding new book functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214
Code 1—our add-new-book.php file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214
Code 2—our add-new-book.php file (updated) . . . . . . . . . . . . . . . . . . . . . . . .214
Code 1—our styles.css file (appended code) . . . . . . . . . . . . . . . . . . . . . . . .216
Code 2—our scripts.js file (updated code) . . . . . . . . . . . . . . . . . . . . . . . . .218
Code 1—our add-new-book.php file (updated code) . . . . . . . . . . . . . . . . . . .219
Code 2—our styles.css file (appended code) . . . . . . . . . . . . . . . . . . . . . . . .220
Code 3—our scripts.js file (updated code) . . . . . . . . . . . . . . . . . . . . . . . . .221
Code 1—our add-new-book.php file (updated PHP code) . . . . . . . . . . . . . . .223
Code 2—our add-new-book.php file (updated HTML code) . . . . . . . . . . . . . .224
Code 2—our styles.css file (appended CSS code) . . . . . . . . . . . . . . . . . . . .226
Listing of catalog functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229
Code 1—finding all the documents from MongoDB collection (updated index.php file) .229
Code 2—displaying the list of all the documents from MongoDB collection by using PHP foreach() construct (updated index.php file—HTML part) .230
Code 3—our updated styles.css file (appended code) . . . . . . . . . . . . . . . .231
Deleting functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232
Code 1—delete code (index.php—no change) . . . . . . . . . . . . . . . . . . . . . . . . . .232
Code 1—delete book functionality (delete-book.php) . . . . . . . . . . . . . . . .234
Code 2—delete book functionality (index.php—small update for displaying an alert after the book is deleted successfully) .235
Edit and update functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
9. MongoDB Step by Step Practical Application Development Using JavaScript (Node.js with Express.js) .237
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238
RESTful Web services using Node.js and MongoDB—an overview . . . . . . . . . . . . . .238
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239
Introduction to API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239
RESTful APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .240
Pre-development steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
Code 1—our index.js file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248
Code 1—update package.json file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248
Developing our APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253
Code 1 (index.js updated) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .255
Code 1 (index.js updated) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .258
Code 1 (index.js updated) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260
Code 2 (JSON body params to be used in Postman) . . . . . . . . . . . . . . . . . . .260
Code 1 (index.js updated) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .263
Code 1 (index.js updated) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
Adding REST API endpoint to delete MongoDB document based on MongoDB document ID (REST DELETE method) .270
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .270
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .271
10. MongoDB Step by Step Practical Mobile App Development Using React Native . .272
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .272
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .273
An overview of our mobile app developed using React Native and MongoDB . .273
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274
Example 1—connecting to MongoDB via API . . . . . . . . . . . . . . . . . . . . . . . . . . .274
Code 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .276
Code 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277
Code 3—API fetch part—networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277
Code 3—style sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .278
Code 4—header section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .278
Code 5—book list section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280
Code 6—return part of the app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281
CORS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .284
Resolving the issue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .284
Change 1 in index.js—adding CORS module using require . . . . . . . . . . . . .287
Change 2 in index.js—enabling CORS in “getAllBPBBooks” route . . . . . .288
Example 2—adding book pictures in the book list section of our mobile app .292
Code 1 (updated App.js file) —CSS section (added some more CSS and changed the class names to “camelCase”) .293
Code 2 (updated App.js File) —update in book list section and use of react native “FlatList” component instead of “.map” method .295
Example 3—adding “Thumbs Up” and “Thumbs Down” in the book list section of our mobile app .301
Code 1 (updated App.js file)—import FontAwesome from Vector Icons .303
Code 2 (updated App.js File)—CSS section (added some more CSS for “Thumbs Up” and “Thumbs Down”) .305
Code 3 (updated App.js file)—added “Thumbs Up” and “Thumbs Down” button components and functions .305
Code 4 (updated App.js file)—book list section (added “Thumbs Up” and “Thumbs Down” button components) .307
Example 4—adding database functionality to “Thumbs Up” and “Thumbs Down” of our mobile app .308
Change 1 in index.js—enabling CORS in “thumbsUPForBPBBook” route . .308
Change 2 in index.js—enabling CORS in “thumbsDOWNForBPBBook” route .309
Code 3 (updated App.js file)—updated “Thumbs Up” and “Thumbs Down” button components, functions, and book list section .312
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .321
11. MongoDB Step by Step Practical Frontend Development Using Python . . . . . . . . . .322
Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .322
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323
An overview of our frontend application developed using Python and MongoDB .323
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .324
Installing Python’s Django framework on Windows operating system . .324
Installation steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .324
HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .358
CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .359
HTML—for file “bpbAppBookDetailsIndex.html” . . . . . . . . . . . . . . . . . . . . . . . . . . . . .384
CSS—for file “style.css” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387
Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .389
Full-Stack Development with MongoDB and Scaling Your Expertise to Web and Mobile App Development is the goal of this book.
Starting with the basics, the book will assist any programmer and developer and those who deal with NodeJS, PHP, Python and React Native in setting up their working environment with MongoDB. Various full-stack configurations of libraries and frameworks for mobile and web applications are covered in length in this book. REST API, CRUD operations are also explained in a detailed manner. The skills you learn to use PHP, ExpressJS, NodeJS, Python and React Native become increasingly solid as time goes on.
Everything in this book has been explained so that, once you begin working on the practical development while reading it, you will be more experienced in software development, both in web and mobile technologies, when you finish reading it.
This book is for individuals interested in learning Full Stack Development with MongoDB and expanding their expertise to design web and mobile applications with MongoDB. Readers with a working knowledge of MongoDB and any programming language can make maximum use of the book.