Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Once attachments have been uploaded to your CouchDB database, you'll want to be able to reference them easily. Let's create a view to help us get all of the attachment names. First, let's navigate to the restaurant database. Then head over to the View dropdown, and select Temporary View. If you have the default function that just emits null on the document, click Run. Now, let's narrow that down to the Attachments field, add in a dot, and then underscore, and then attachments.
You'll notice that some of our documents don't have an attachments field, while the other ones do. We want to have a function that only returns the documents that have attachments. So let's go to the exercise files and get one. Open up map.js and copy the function. Then paste that function over the existing map function. The ultimate goal here is to get one file name per document.
This view has everything we need. We have the document name as the key, and the file name as the value. We also have the document ID handy. This will help us construct the URLs we need to point to the images. Now, let's click Save As so we can save this view. For the design document, type menu, and for the view name type items. So now we have this as a permanent view in our system. We can also view the raw data. Remove everything from the question mark down to the root.
So now we have that same data available in JSON format. Creating a view is helpful for getting a clean list of attachment file names. With this view in place, you can now easily build applications based around it.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 93436 Viewers
82 Video lessons · 104356 Viewers
71 Video lessons · 76434 Viewers
56 Video lessons · 107771 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.