Class: LocalStorageAdapter

LocalStorageAdapter


new LocalStorageAdapter(opts)

LocalStorageAdapter class.

Parameters:
Name Type Argument Description
opts Object <optional>

Configuration opts.

Properties
Name Type Argument Default Description
basePath string <optional>
''

TODO

debug boolean <optional>
false

TODO

storeage Object <optional>
localStorage

TODO

Source:
Example
import {DataStore} from 'js-data'
import LocalStorageAdapter from 'js-data-localstorage'
const store = new DataStore()
const adapter = new LocalStorageAdapter()
store.registerAdapter('ls', adapter, { 'default': true })

Members


<static> version :Object

Details of the current version of the js-data-localstorage module.

Type:
  • Object
Properties:
Name Type Description
version.full string

The full semver value.

version.major number

The major version number.

version.minor number

The minor version number.

version.patch number

The patch version number.

version.alpha string | boolean

The alpha version value, otherwise false if the current version is not alpha.

version.beta string | boolean

The beta version value, otherwise false if the current version is not beta.

Source:

basePath :string

TODO

Type:
  • string
Source:

debug :boolean

TODO

Type:
  • boolean
Default Value:
  • false
Source:

returnDeletedIds :boolean

TODO

Type:
  • boolean
Default Value:
  • false
Source:

storage :Object

TODO

Type:
  • Object
Default Value:
  • localStorage
Source:

Methods


<static> extend(instanceProps, classProps)

Alternative to ES6 class syntax for extending LocalStorageAdapter.

Parameters:
Name Type Argument Description
instanceProps Object <optional>

Properties that will be added to the prototype of the subclass.

classProps Object <optional>

Properties that will be added as static properties to the subclass itself.

Source:
Returns:

Subclass of LocalStorageAdapter.

Type
Object

afterCreate()

Source:

afterCreateMany()

Source:

afterDestroy()

Source:

afterDestroyAll()

Source:

afterFind()

Source:

afterFindAll()

Source:

afterUpdate()

Source:

afterUpdateAll()

Source:

afterUpdateMany()

Source:

beforeCreate()

Source:

beforeCreateMany()

Source:

beforeDestroy()

Source:

beforeDestroyAll()

Source:

beforeFind()

Source:

beforeFindAll()

Source:

beforeUpdate()

Source:

beforeUpdateAll()

Source:

beforeUpdateMany()

Source:

create(mapper, props, opts)

Create a new record.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

props Object

The record to be created.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw boolean <optional>
false

TODO

Source:
Returns:
Type
Promise

createMany(mapper, props, opts)

Create multiple records in a single batch.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

props Array

Array of records to be created.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw boolean <optional>
false

TODO

Source:
Returns:
Type
Promise

dbg()

Source:

destroy(mapper, id, opts)

Destroy the record with the given primary key.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

id string | number

Primary key of the record to destroy.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw boolean <optional>
false

TODO

Source:
Returns:
Type
Promise

destroyAll(mapper, query, opts)

Destroy the records that match the selection query.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

query Object

Selection query.

opts Object <optional>

Configuration opts.

Properties
Name Type Argument Default Description
raw boolean <optional>
false

TODO

Source:
Returns:
Type
Promise

ensureId()

TODO

Source:

find(mapper, id, opts)

Retrieve the record with the given primary key.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

id string | number

Primary key of the record to retrieve.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw boolean <optional>
false

TODO

with Array.<string> <optional>
[]

TODO

Source:
Returns:
Type
Promise

findAll(mapper, query, opts)

Retrieve the records that match the selection query.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

query Object

Selection query.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw boolean <optional>
false

TODO

with Array.<string> <optional>
[]

TODO

Source:
Returns:
Type
Promise

getIdPath()

TODO

Source:

getIds()

TODO

Source:

getPath()

TODO

Source:

getRaw()

TODO

Source:

log()

TODO

Source:

removeId()

TODO

Source:

saveKeys()

TODO

Source:

update(mapper, id, props, opts)

Update the records that match the selection query. If a record with the specified primary key cannot be found then no update is performed and the promise is resolved with undefined.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

id string | number

The primary key of the record to be updated.

props Object

The update to apply to the record.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw boolean <optional>
false

TODO

Source:
Returns:
Type
Promise

updateAll(mapper, props, query, opts)

Update the records that match the selection query.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

props Object

The update to apply to the selected records.

query Object

Selection query.

opts Object <optional>

Configuration options.

Source:
Returns:
Type
Promise

updateMany(mapper, records, opts)

Update the given records in a single batch.

Parameters:
Name Type Argument Description
mapper Object

The mapper.

records Object

The records to update.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw boolean <optional>
false

TODO

Source:
Returns:
Type
Promise