API Docs for: 2.7.3
Show:

SA_DatabaseManager Class

Module: Component
Parent Module: Wanaplan

An IndexedDB database manager. The constructor will try to normalize all prefixed objects.

Constructor

SA_DatabaseManager

()

Methods

clear

(
  • success
  • error
)

Clear all plans from the database.

Parameters:

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.

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.

Parameters:

  • success Function

    A function called when the manager is ready.

  • error Function

    A function called when an error occured.

isAvailable

() Boolean

Indicates whether IndexedDB is available or not in the user's browser.

Returns:

Boolean:

Returns true if available otherwise it returns false.

loadItem

(
  • id
  • success
  • error
)

Load a structure of the specified plan.

Parameters:

  • id Number

    The plan's id

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.

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.

Parameters:

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.

removeItem

(
  • id
  • success
  • error
)

Remove a plan from the database.

Parameters:

  • id Number

    The plan's id to delete.

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.

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.

Parameters:

  • plan Object

    The plan to save.

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.