Vous êtes sur la page 1sur 3

(/)

Courses (/courses) Help (/help) About (/about) Blog (http://ed-blog.mongodb.com/) DMAKETAS (/DASHBOARD)

M101J: MongoDB for Java Developers


Courseware (/courses/10gen/M101J/2013_October/courseware) Discussion (/courses/10gen/M101J/2013_October/discussion/forum) Progress (/courses/10gen/M101J/2013_October/progress) Course Info (/courses/10gen/M101J/2013_October/info) Wiki (/courses/10gen/M101J/2013_October/course_wiki)

SEARCH

Homework: HW 3.3
Making your blog accept comments In this homework you will add code to your blog so that it accepts comments. You will be using the same code as you downloaded for HW 3.2. Once again, the area where you need to work is marked with an XXX in the BlogPostsDAO class. There is only a single location you need to work to insert comments. You don't need to figure out how to retrieve comments for this homework because the code you did in 3.2 already pulls the entire blog post (unless you specifically projected to eliminate the comments) and we gave you the code in the template that pulls them out of the JSON document. This assignment has fairly little code, but it's a little more subtle than the previous assignment because you are going to be manipulating an array within the Mongo document. For the sake of clarity, here is a document out of the posts collection from a working project that also has comments.

{ " _ i d ":O b j e c t I d ( " 5 1 3 d 3 9 6 d a 0 e e 6 e 5 8 9 8 7 b a e 7 4 " ) , " a u t h o r ":" a n d r e w " , " b o d y ":" R e p r e s e n t a t i v e sf r o mt h ep l a n e tM a r sa n n o u n c e dt o d a yt h a tt h ep l a n e tw o u l da d o p tM o n g o D Ba sa p l a n e t a r ys t a n d a r d .H e a dM a r t i a nF l i p b l i ps a i dt h a tM o n g o D Bw a st h ep e r f e c tt o o lt os t o r et h ed i v e r s i t yo fl i f e t h a te x i s t so nM a r s . " , " c o m m e n t s ":[ { " a u t h o r ":" L a r r yE l l i s o n " , " b o d y ":" W h i l eIa md e e p l yd i s a p p o i n t e dt h a tM a r sw o n ' tb es t a n d a r d i z i n go na r e l a t i o n a ld a t a b a s e ,Iu n d e r s t a n dt h e i rd e s i r et oa d o p tam o r em o d e r nt e c h n o l o g yf o rt h er e dp l a n e t . " , " e m a i l ":" l a r r y @ o r a c l e . c o m " } , { " a u t h o r ":" S a l v a t o r eS a n f i l i p p o " , " b o d y ":" T h i sm a k en os e n s et om e .R e d i sw o u l dh a v ew o r k e df i n e . " }

} ] , " d a t e ":I S O D a t e ( " 2 0 1 3 0 3 1 1 T 0 1 : 5 4 : 5 3 . 6 9 2 Z " ) , " p e r m a l i n k ":" m a r t i a n s _ t o _ u s e _ m o n g o d b " , " t a g s ":[ " m a r t i a n s " , " s e t i " , " n o s q l " , " w o r l d d o m i n a t i o n " ] , " t i t l e ":" M a r t i a n st ou s eM o n g o D B " }

Note that you add comments in this blog from the blog post detail page, which appears at
h t t p : / / l o c a l h o s t : 8 0 8 2 / p o s t / p o s t _ s l u g

where post_slug is the permalink. For the sake of eliminating doubt, the permalink for the example blog post above is http://localhost:8082/post/martians_to_use_mongodb You will run validate.py to check your work, much like the last problem. Validate.py will run through and check the requirements of HW 3.2 and then will check to make sure it can add blog comments, as required by this problem, HW 3.3. It checks the web output as well as the database documents. This validate.py program will print out a 3.3 validation code that you should enter below.
p y t h o nv a l i d a t e . p y

Once you have the validation code, please copy and paste in the box below, no spaces.

ihfr48nf89jk09309kj0d2d HIDE ANSWER You have used 0 of 3 submissions

Products & Services (http://www.mongodb.com/products/mongodb) Events (http://www.mongodb.com/events) Partners (http://www.mongodb.com/partners) Customers (http://www.mongodb.com/customers) About MongoDB (http://www.mongodb.com/about) Contact Us (/contact) Careers (http://www.mongodb.com/careers)

(https://twitter.com/mongodbinc)

(http://www.facebook.com/mongodb)

(http://www.linkedin.com/company/783611)

(https://plus.google.com/101024085748034940765/posts) (http://edx.org) (http://www.mongodb.com)


2013 MongoDB, Inc. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB Inc.