Classes
Methods
(async, abstract) add(item) → {Promise.<boolean>}
Adds the given item to the collection. Semantics (allowing or rejecting duplicates) depend on the concrete subclass.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
any | The item to add. |
- Source:
Returns:
True if the collection was modified.
- Type
- Promise.<boolean>
(async) addAll(items) → {Promise.<Array.<any>>}
Adds all items from an iterable.
Parameters:
| Name | Type | Description |
|---|---|---|
items |
Iterable.<any> | AsyncIterable.<any> | Items to add. |
- Source:
Returns:
List of actually added items.
- Type
- Promise.<Array.<any>>
(async, abstract) clear() → {Promise.<Boolean>}
Removes all items from the collection.
- Source:
Returns:
- Type
- Promise.<Boolean>
(async) create(item) → {Promise.<boolean>}
Create (C in CRUD) Adds a new item if it is not already present.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
any | The item to create. |
- Source:
Returns:
True if the collection was modified.
- Type
- Promise.<boolean>
(async) delete(item) → {Promise.<boolean>}
Delete (D in CRUD) Removes an item from the collection.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
any | The item to delete. |
- Source:
Returns:
True if the collection was modified.
- Type
- Promise.<boolean>
(async) deleteAll(items) → {Promise.<Array.<any>>}
Delete Many (extended CRUD)
Removes all given items from the collection.
Alias of removeAll.
Parameters:
| Name | Type | Description |
|---|---|---|
items |
Iterable.<any> | AsyncIterable.<any> | Items to delete. |
- Source:
Returns:
List of actually removed items.
- Type
- Promise.<Array.<any>>
(abstract) get(query) → {AsyncEach.<any>}
Retrieves items matching a given query. In the simplest case, the query is an item, and all equivalent items are returned. Subclasses may support richer query semantics.
Parameters:
| Name | Type | Description |
|---|---|---|
query |
any | The query object or value. |
- Source:
Returns:
A fluent AsyncEAch of all matching items.
- Type
- AsyncEach.<any>
(async, abstract) has(item) → {Promise.<boolean>}
Checks whether the collection contains the given item.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
any | The item to test for membership. |
- Source:
Returns:
True if the item is present.
- Type
- Promise.<boolean>
(async) isEmpty() → {Promise.<boolean>}
Checks whether the collection is empty.
- Source:
Returns:
True if the collection has no items.
- Type
- Promise.<boolean>
(async, abstract) n() → {Promise.<number>}
Returns the number of items in the collection.
- Source:
Returns:
- Type
- Promise.<number>
query(query) → {AsyncEach.<any>}
Alias for get, for database-style terminology.
Parameters:
| Name | Type | Description |
|---|---|---|
query |
any | The query to evaluate. |
- Source:
Returns:
All matching items.
- Type
- AsyncEach.<any>
(async) read(item) → {Promise.<(any|undefined)>}
Read (R in CRUD)
Returns a single matching item, or undefined if none exist.
Retrieves the "first" match from get.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
any | The item or query to read. |
- Source:
Returns:
The matching item or undefined.
- Type
- Promise.<(any|undefined)>
readAll(query) → {AsyncIterable.<any>}
Read All (extended CRUD) Returns all items that match the given query.
Parameters:
| Name | Type | Description |
|---|---|---|
query |
any | The query to evaluate. |
- Source:
Returns:
All matching items.
- Type
- AsyncIterable.<any>
(async, abstract) remove(item) → {Promise.<boolean>}
Removes the given item from the collection.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
any | The item to remove. |
- Source:
Returns:
True if the collection was modified.
- Type
- Promise.<boolean>
(async) removeAll(items) → {Promise.<Array.<any>>}
Removes all given items from the collection.
Parameters:
| Name | Type | Description |
|---|---|---|
items |
Iterable.<any> | AsyncIterable.<any> | Items to remove. |
- Source:
Returns:
List of actually removed items.
- Type
- Promise.<Array.<any>>
(async) update(oldItem, newItem, upsertopt) → {Promise.<boolean>}
Update (U in CRUD)
Replaces an existing item with a new one.
Inserts the new item if upsert is true and old item is not found.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
oldItem |
any | The item to be replaced. |
||
newItem |
any | The new item to insert. |
||
upsert |
boolean |
<optional> |
false | Whether to insert if |
- Source:
Returns:
True if updated or inserted, false otherwise.
- Type
- Promise.<boolean>