Created
December 12, 2012 12:44
-
-
Save anonymous/4267456 to your computer and use it in GitHub Desktop.
Couch DB, relate data sets of users and uploaded documents. Currently times out.
This file contains 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
var cradle = require('cradle'); | |
var usersdb = new(cradle.Connection)().database('users'); | |
var documentsdb = new(cradle.Connection)().database('documents'); | |
/* | |
* GET users listing. | |
*/ | |
exports.user = getUser; | |
function getUser (req, res){ | |
usersdb.get(req.params.username, function (err, doc) { | |
for (var i = 0;i <= doc.documents.length;i++){ | |
//cycle the documents through getDocument | |
doc.documents[i] = getDocument(doc.documents[i]); | |
} | |
// render the paths and names of the documents (currently undefined) | |
res.render('user', doc); | |
}); | |
} | |
function getDocument (documentID) { | |
var response = true; | |
documentsdb.get(documentID, function (err, doc) { | |
//get the path and name of each document from documents db | |
response = doc; | |
}); | |
while (response){} | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment