Class: MemoryStore

MemoryStore(optionsopt)

A resource store backed by a Map.

Constructor

new MemoryStore(optionsopt)

Parameters:
Name Type Attributes Description
options object <optional>

Store options

Properties
Name Type Attributes Description
idField string <optional>

Name of the identifier field

items Array.<object> <optional>

Items to seed the store with

Source:

Classes

MemoryStore

Methods

clear() → {void}

Remove every item.

Source:
Returns:
Type
void

create(body) → {object}

Create an item, assigning an identifier when the body does not carry one.

Parameters:
Name Type Description
body object

Item body

Source:
Returns:

Created item

Type
object

get(id) → {object|undefined}

Read one item.

Parameters:
Name Type Description
id *

Identifier

Source:
Returns:

Item, or undefined when absent

Type
object | undefined

list(query) → {Object}

Run a collection query against the store.

Parameters:
Name Type Description
query object

Query from parseCollectionQuery

Source:
Returns:

Collection envelope

Type
Object

normalizeId(id) → {*}

Normalise an identifier so that "1" from a path matches the stored 1.

Parameters:
Name Type Description
id *

Raw identifier

Source:
Returns:

Normalised identifier

Type
*

patch(id, body) → {object|undefined}

Merge changes into an item.

Parameters:
Name Type Description
id *

Identifier

body object

Partial body

Source:
Returns:

Updated item, or undefined when absent

Type
object | undefined

remove(id) → {boolean}

Delete an item.

Parameters:
Name Type Description
id *

Identifier

Source:
Returns:

True when an item was deleted

Type
boolean

update(id, body) → {object|undefined}

Replace an item.

Parameters:
Name Type Description
id *

Identifier

body object

Replacement body

Source:
Returns:

Updated item, or undefined when absent

Type
object | undefined