Module: DataManager

AeroGear. DataManager

new DataManager(config) → {object}

Status: Stable
A collection of data connections (stores) and their corresponding data models. This object provides a standard way to interact with client side data no matter the data format or storage mechanism used.
Parameters:
Name Type Argument Description
config String | Array | Object <optional>
A configuration for the store(s) being created along with the DataManager. If an object or array containing objects is used, the objects can have the following properties:
Properties
Name Type Argument Default Description
name String the name that the store will later be referenced by
type String <optional>
"Memory" the type of store as determined by the adapter used
recordId String <optional>
"id" @deprecated the identifier used to denote the unique id for each record in the data associated with this store
settings Object <optional>
{} the settings to be passed to the adapter. For specific settings, see the documentation for the adapter you are using.
Properties
Name Type Argument Default Description
fallback Boolean <optional>
true falling back to a supported adapter is on by default, to opt-out, set this setting to false
preferred Array <optional>
a list of preferred adapters to try when falling back. Defaults to [ "IndexedDB", "WebSQL", "SessionLocal", "Memory" ]
Source:
Returns:
dataManager - The created DataManager containing any stores that may have been created
Type
object
Example
// Create an empty DataManager
var dm = AeroGear.DataManager();

// Create a single store using the default adapter
var dm2 = AeroGear.DataManager( "tasks" );

// Create multiple stores using the default adapter
var dm3 = AeroGear.DataManager( [ "tasks", "projects" ] );

// Create a custom store
var dm3 = AeroGear.DataManager({
    name: "mySessionStorage",
    type: "SessionLocal",
    id: "customID"
});

// Create multiple custom stores
var dm4 = AeroGear.DataManager([
    {
        name: "mySessionStorage",
        type: "SessionLocal",
        id: "customID"
    },
    {
        name: "mySessionStorage2",
        type: "SessionLocal",
        id: "otherId",
        settings: { ... }
    }
]);

Extends

  • AeroGear.Core

Members

<static> adapters

The adapters object is provided so that adapters can be added to the AeroGear.DataManager namespace dynamically and still be accessible to the add method
Source:

<static> preferred

preferred adapters for the fallback strategy
Source:

<static> this.collectionName :Object

The name used to reference the collection of data store instances created from the adapters
Type:
  • Object
Default Value:
  • stores
Source:

<static> validAdapters

Stores the valid adapters
Source:

Methods

<static> validateAdapter()

Method to determine and store what adapters are valid for this environment
Source: