diff --git a/node/db/API.js b/node/db/API.js index 9912b098d..03862ad9e 100644 --- a/node/db/API.js +++ b/node/db/API.js @@ -33,7 +33,7 @@ var async = require("async"); exports.createGroup = groupManager.createGroup; exports.createGroupIfNotExistsFor = groupManager.createGroupIfNotExistsFor; exports.deleteGroup = groupManager.deleteGroup; -exports.listPads = groupManager.listPads; +exports.listGroupPads = groupManager.listGroupPads; exports.createGroupPad = groupManager.createGroupPad; /**********************/ @@ -57,6 +57,15 @@ exports.listSessionsOfAuthor = sessionManager.listSessionsOfAuthor; /**PAD CONTENT FUNCTIONS*/ /************************/ + +exports.listAllPads = function(callback) +{ + padManager.listAllPads(callback); + +} + + + /** getText(padID, [rev]) returns the text of a pad diff --git a/node/db/GroupManager.js b/node/db/GroupManager.js index 1598e72e1..e4ef47dfa 100644 --- a/node/db/GroupManager.js +++ b/node/db/GroupManager.js @@ -244,7 +244,7 @@ exports.createGroupPad = function(groupID, padName, text, callback) }); } -exports.listPads = function(groupID, callback) +exports.listGroupPads = function(groupID, callback) { exports.doesGroupExist(groupID, function(err, exists) { diff --git a/node/db/Pad.js b/node/db/Pad.js index bba7562c8..48bc361bc 100644 --- a/node/db/Pad.js +++ b/node/db/Pad.js @@ -380,7 +380,19 @@ Class('Pad', { else { var firstChangeset = Changeset.makeSplice("\n", 0, 0, exports.cleanText(text)); - + db.get("allpads",function(err,data) + { + if(err) callback(err); + if(data){ + data.push(_this.id); + db.set("allpads",data); + + } + else { + db.set("allpads",[_this.id]); + } + + }); _this.appendRevision(firstChangeset, ''); } @@ -471,6 +483,21 @@ Class('Pad', { { db.remove("pad:"+padID); padManager.unloadPad(padID); + + // delete entry from allpads + db.get("allpads",function(err,data) + { + if(err) callback(err); + if(data){ + delete data[padID]; + db.set("allpads",data); + } + else{ + //nothing to do, although there should be an entry + } + + }); + callback(); } ], function(err) diff --git a/node/db/PadManager.js b/node/db/PadManager.js index 8af299ccc..200be61ba 100644 --- a/node/db/PadManager.js +++ b/node/db/PadManager.js @@ -113,3 +113,18 @@ exports.unloadPad = function(padId) if(globalPads[padId]) delete globalPads[padId]; } + +exports.listAllPads = function(callback) +{ + db.get("allpads",function(err,data) + { + if(err) callback(err); + if(data){ + callback(err,data); + } + else callback(err,[]); + + }); + + +}