better logic for author handling
This commit is contained in:
parent
5f9bbd0666
commit
cb65224997
|
@ -24,12 +24,25 @@ exports.setPadRaw = function(padId, records, callback){
|
|||
async.eachSeries(Object.keys(records), function(key, cb){
|
||||
var value = records[key]
|
||||
|
||||
// we know its an author
|
||||
// Author data
|
||||
if(value.padIDs){
|
||||
// rewrite author pad ids
|
||||
value.padIDs[padId] = 1;
|
||||
var newKey = key;
|
||||
|
||||
// Does this author already exist?
|
||||
db.get(key, function(err, author){
|
||||
if(author){
|
||||
// Yes, add the padID to the author..
|
||||
author.padIDs.push(padId);
|
||||
value = author;
|
||||
}else{
|
||||
// No, create a new array with the author info in
|
||||
value.padIDs = [padId];
|
||||
}
|
||||
});
|
||||
|
||||
// Not author data, probably pad data
|
||||
}else{
|
||||
// we can split it to look to see if its pad data
|
||||
var oldPadId = key.split(":");
|
||||
|
|
Loading…
Reference in New Issue