new LocalStorageAdapter(opts)
LocalStorageAdapter class.
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
<optional> |
Configuration opts. Properties
|
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
- Source:
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. -
basePath :string
-
TODO
Type:
- string
-
debug :boolean
-
TODO
Type:
- boolean
-
returnDeletedIds :boolean
-
TODO
Type:
- boolean
-
storage :Object
-
TODO
Type:
- Object
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.
Returns:
Subclass of
LocalStorageAdapter
.- Type
- Object
-
afterCreate()
-
afterCreateMany()
-
afterDestroy()
-
afterDestroyAll()
-
afterFind()
-
afterFindAll()
-
afterUpdate()
-
afterUpdateAll()
-
afterUpdateMany()
-
beforeCreate()
-
beforeCreateMany()
-
beforeDestroy()
-
beforeDestroyAll()
-
beforeFind()
-
beforeFindAll()
-
beforeUpdate()
-
beforeUpdateAll()
-
beforeUpdateMany()
-
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
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
Returns:
- Type
- Promise
-
dbg()
-
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
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
Returns:
- Type
- Promise
-
ensureId()
-
TODO
-
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
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
Returns:
- Type
- Promise
-
getIdPath()
-
TODO
-
getIds()
-
TODO
-
getPath()
-
TODO
-
getRaw()
-
TODO
-
log()
-
TODO
-
removeId()
-
TODO
-
saveKeys()
-
TODO
-
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 withundefined
.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
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.
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
Returns:
- Type
- Promise