Classes
Members
size
Size getter (ergonomic alias for n()). Read-only property.
- Source:
Methods
(abstract) add(item) → {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
- boolean
addAll(items) → {Array.<any>}
Adds all items from an iterable.
Parameters:
| Name | Type | Description |
|---|---|---|
items |
Iterable.<any> | Items to add. |
- Source:
Returns:
List of actually removed items.
- Type
- Array.<any>
(abstract) clear() → {boolean}
Removes all items from the collection.
- Source:
Returns:
True if the collection was cleared.
- Type
- boolean
create(item) → {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
- boolean
delete(item) → {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
- boolean
deleteAll(items) → {boolean}
Delete Many (extended CRUD):
Removes all the given items from the collection.
Alias of removeAll.
Parameters:
| Name | Type | Description |
|---|---|---|
items |
Iterable.<any> | Items to delete. |
- Source:
Returns:
True if all the items were removed.
- Type
- boolean
(abstract) get(query) → {Iterable.<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:
An iterable of all matching items.
- Type
- Iterable.<any>
(abstract) has(item) → {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, false otherwise.
- Type
- boolean
isEmpty() → {boolean}
Checks whether the collection is empty.
- Source:
Returns:
True if the collection has no items.
- Type
- boolean
let(item) → {Collection}
Adds the given item and returns the collection (fluent API).
Parameters:
| Name | Type | Description |
|---|---|---|
item |
any | The item to add. |
- Source:
Returns:
The collection itself.
- Type
- Collection
(abstract) n() → {number}
Returns the number of items in the collection.
- Source:
Returns:
- Type
- number
query(query) → {Iterable.<any>}
Alias for get, for database-style terminology.
Parameters:
| Name | Type | Description |
|---|---|---|
query |
any | The query to evaluate. |
- Source:
Returns:
All matching items.
- Type
- Iterable.<any>
read(item) → {any|undefined}
Read (R in CRUD):
Returns a single matching item, or undefined if none exist.
By default, this 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
- any | undefined
readAll(query) → {Iterable.<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
- Iterable.<any>
(abstract) remove(item) → {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
- boolean
removeAll(items) → {Array.<any>}
Removes all given items from the collection.
Parameters:
| Name | Type | Description |
|---|---|---|
items |
Iterable.<any> | Items to remove. |
- Source:
Returns:
List of actually removed items.
- Type
- Array.<any>
update(oldItem, newItem, upsertopt) → {boolean}
Update (U in CRUD):
Replaces an existing item with a new one.
If the old item does not exist, inserts the new item if upsert is true.
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
- boolean