Created
April 8, 2013 16:07
-
-
Save davetapley/5338014 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.routes = function() { | |
| this.get('/', function() { | |
| var users = db.collection('users'); | |
| this.res.setHeader("Content-Type", 'text/html'); | |
| this.res.writeHead(200, {}); | |
| var that = this; | |
| var stream = users.find().forEach(function(err, userDoc) { | |
| if(userDoc) { | |
| that.res.write('<h1>' + userDoc._id + '</h1>'); | |
| that.res.write(JSON.stringify(userDoc)); | |
| if(userDoc.subscriptions) { | |
| that.res.write('<ul>'); | |
| userDoc.subscriptions.forEach(function(err, userSubscription) { | |
| if(userSubscription) { | |
| that.res.write('<li>' + userSubscription + '</h1>'); | |
| } else { | |
| that.res.write('<ul>'); | |
| } | |
| }); | |
| } | |
| } else { | |
| that.res.end(); | |
| return; | |
| } | |
| }); | |
| }); | |
| } | |
Author
Author
We're good down to line 12, but the if on line 14 is never true.
The goal is that if a user has subscriptions, their keys (e.g. facebook) should be printed in a ul.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dbcomes frommongojs.The exported
routesare added todirectorlike this:The
userscollection looks like this: