This commit is contained in:
John McLear 2014-12-29 22:51:31 +01:00
parent a2262c56b9
commit ec2b844f94
1 changed files with 25 additions and 1 deletions

View File

@ -22,6 +22,8 @@ var ERR = require("async-stacktrace");
exports.getPadRaw = function(padId, callback){ exports.getPadRaw = function(padId, callback){
async.waterfall([ async.waterfall([
function(cb){ function(cb){
// Get the Pad available content keys
db.findKeys("pad:"+padId+"*", null, function(err,records){ db.findKeys("pad:"+padId+"*", null, function(err,records){
if(!err){ if(!err){
cb(err, records); cb(err, records);
@ -30,15 +32,37 @@ exports.getPadRaw = function(padId, callback){
}, },
function(records, cb){ function(records, cb){
var data = {}; var data = {};
async.forEachSeries(Object.keys(records), function(key, r){ async.forEachSeries(Object.keys(records), function(key, r){
// For each piece of info about a pad.
db.get(records[key], function(err, entry){ db.get(records[key], function(err, entry){
data[records[key]] = entry; data[records[key]] = entry;
// Get the Pad Authors
if(entry.pool && entry.pool.numToAttrib){
var authors = entry.pool.numToAttrib;
async.forEachSeries(Object.keys(authors), function(k, c){
if(authors[k][0] === "author"){
var authorId = authors[k][1];
// Get the author info
db.get("globalAuthor:"+authorId, function(e, authorEntry){
if(!e) data["globalAuthor:"+authorId] = authorEntry;
});
}
// console.log("authorsK", authors[k]);
c(null);
});
}
r(null); // callback; r(null); // callback;
}); });
}, function(err){ }, function(err){
cb(err, data); cb(err, data);
}) })
}], function(err, data){ }
], function(err, data){
callback(null, data); callback(null, data);
}); });
} }