If you take a look at Using scriptDB, you'll see that i use the cScriptDb functions from the mcpher library. This has some built in stuff including the following.
When you are working with your badge environment, you are probably going to need to take a look inside, and possibly manipulate, some scriptDB. Here are a few examples using the silo manager. In this example, I've included these in my awards manager code. That means I'm using a local scriptDB (ScriptDb.getMyDb()). You can of course write this code in a different script, and attach your awards manager as a library and instead refer to that library's scriptDB. Showing all awards in the databaseBecause I'm using a silo, this will only show award records. Anything else in your scriptdb will be ignored function showAll() { var stuffSilo = mcpher.scriptDbSilo(mcpher.EBADGES.award,ScriptDb.getMyDb()); var results = stuffSilo.query({}); while (results.hasNext()) { var result = results.next(); Logger.log(JSON.stringify(result)); } } Deleting all the awardsBe careful if you have awarded badges. This will mean that the mozilla backpack will not be able to find the assertion. function deleteAll() { mcpher.scriptDbSilo(mcpher.EBADGES.award,ScriptDb.getMyDb()).remove(); } Showing just my recordsThis will limit to only the records created by the currently logged on google user. Note that the optional encryption parameter must match how you wrote the record. In the case of awards records, the awardee email address is always one way encrypted. function showAllMine() { var stuffSilo = mcpher.scriptDbSilo(mcpher.EBADGES.award,ScriptDb.getMyDb(),true,true,true); var results = stuffSilo.query({}); while (results.hasNext()) { var result = results.next(); Logger.log(JSON.stringify(result)); } } Deleting just my recordsThis will limit to only the records created by the currently logged on google user. Note that the optional encryption parameter must match how you wrote the record. In the case of awards records, the awardee email address is always one way encrypted. Be careful if you have awarded badges. This will mean that the mozilla backpack will not be able to find the assertion. function deleteAllMine() { mcpher.scriptDbSilo(mcpher.EBADGES.award,ScriptDb.getMyDb(),true,true,true).remove(); } Deleting a record by keyDuring the beta testing period, I also provide a way of deleting a record by key through URL. For example, something like this would delete a specific award record by key. https://script.google.com/macros/s/AKfycbxZYXHPZrXkxJzeTiz7PJ-5th0g0w7s0DmxXR3o1v4AVSlmwBM/exec?key=324145545dc44c60dba232e7c07fcc0c0dcfeb094f1bafea125aa22f24aa992x&action=remove cScriptDB silo codeTo see how all that works, take a look at the code for cScriptDB
|
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Things that have been deprecated > Badges >