SA_DatabaseManager
Summary
An IndexedDB database manager. The constructor will try to normalize all prefixed objects.
Constructor
SA_DatabaseManager
Syntax
SA_DatabaseManager
()
Summary
Item Index
Methods
clear
Syntax
clear
-
success
-
error
Summary
Clear all plans from the database.
initialize
Syntax
initialize
-
success
-
error
Summary
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
Syntax
Summary
Indicates whether IndexedDB is available or not in the user's browser.
Returns:
Returns true
if available otherwise it returns false
.
loadItem
Syntax
loadItem
-
id
-
success
-
error
Summary
Load a structure of the specified plan.
loadItems
Syntax
loadItems
-
success
-
error
Summary
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
Syntax
removeItem
-
id
-
success
-
error
Summary
Remove a plan from the database.
saveItem
Syntax
saveItem
-
plan
-
success
-
error
Summary
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.