Skip to content

Instantly share code, notes, and snippets.

@janl
Forked from anonymous/gist:4267456
Created December 12, 2012 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janl/4271837 to your computer and use it in GitHub Desktop.
Save janl/4271837 to your computer and use it in GitHub Desktop.
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