Initializing the Application
Now that the application is created, you need to also create the Page and Photo documents in the database. You can do this in several different ways. For example, you can add this ability directly to your application, which is a good way to go if you need it there later. Or you can use a JavaScript script directly in the MongoDB shell that includes the appropriate commands to create the documents. Or you can write a simple script in Node.js or some other language that supports accessing MongoDB.
Listing 27.19 shows a basic script that creates the Page document and adds several Photo documents as well. Each Page and Photo document also has a CommentThread document created and associated with the commentId reference. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access