SA_DatabaseManager Class
An IndexedDB database manager. The constructor will try to normalize all prefixed objects.
Constructor
SA_DatabaseManager
()
Item Index
Methods
clear
-
success
-
error
Clear all plans from the database.
initialize
-
success
-
error
Initialize the manager. If the object store doesn't exists then it's created. The success callback is called when all operations are done.
isAvailable
()
Boolean
Indicates whether IndexedDB is available or not in the user's browser.
Returns:
Returns true
if available otherwise it returns false
.
loadItem
-
id
-
success
-
error
Load a structure of the specified plan.
loadItems
-
success
-
error
Loads all plans from the database without their structures (id, name, screenshot).
If you want to load structures too then you need to set the complete
parameter to true
.
An array of plans objects is available in the first callback parameter.
removeItem
-
id
-
success
-
error
Remove a plan from the database.
saveItem
-
plan
-
success
-
error
Save a plan into the database. The plan's id is updated. The structure of the object stored is:
- id {Number} If it isn't set then a new record is created otherwise it's updated.
- name {String} The plan's name.
- structure {String} A serialized string of the structure.
- screenshot {String} A base64 string.