dbtest.js 543 B

123456789101112131415161718
  1. console.log("Testing Database API");
  2. if (newDBTableIfNotExists("testdb")){
  3. if (writeDBItem("testdb","message","Hello World")){
  4. //Test suceed. Set Response message to the message
  5. sendResp("Database access return value: " + readDBItem("testdb","message"));
  6. //Delete the entry
  7. console.log("Delete entry:" + deleteDBItem("testdb","message"))
  8. //Drop the table after testing
  9. dropDBTable("testdb");
  10. console.log("Testdb table dropped");
  11. }else{
  12. sendResp("Failed to write to db");
  13. }
  14. }else{
  15. sendResp("Failed creating new db");
  16. }