This commit is contained in:
John McLear 2014-12-29 22:51:31 +01:00
parent a2262c56b9
commit ec2b844f94

View file

@ -22,6 +22,8 @@ var ERR = require("async-stacktrace");
exports.getPadRaw = function(padId, callback){
async.waterfall([
function(cb){
// Get the Pad available content keys
db.findKeys("pad:"+padId+"*", null, function(err,records){
if(!err){
cb(err, records);
@ -30,15 +32,37 @@ exports.getPadRaw = function(padId, callback){
},
function(records, cb){
var data = {};
async.forEachSeries(Object.keys(records), function(key, r){
// For each piece of info about a pad.
db.get(records[key], function(err, 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;
});
}, function(err){
cb(err, data);
})
}], function(err, data){
}
], function(err, data){
callback(null, data);
});
}