import Collection from 'node-collections-boilerplate/node-collections-boilerplate-nahid/Collection.js'
Collection
Should be the class that programs interact with.
It should take care of syncing data between storage and search.
Static Method Summary
Static Public Methods | ||
public static |
create(storage: *, search: *, Class: *): * Helper creation method |
Constructor Summary
Public Constructor | ||
public |
constructor(options;: object) |
Member Summary
Public Members | ||
public |
name of collection |
|
public |
id field of records |
|
public |
instance of Search |
|
public |
searchMeta: SearchMeta search definition |
|
public |
where data is stored |
Method Summary
Public Methods | ||
public |
async createRecord(record: *): * Add a new record to collection. |
|
public |
async deleteRecord(record: *): * Delete a record from collection |
|
public |
async initialise(): * Call this to connect to storage units and search |
|
public |
readRecord(record: *): * Read an existing record. |
|
public |
async searchRecords(query: *): {"results": *} Search for records in collection using query. |
|
public |
stripRecord(record: *, extra: *[]): * Strips a record to return as search result. |
|
public |
updateField(record: *, field: *, value: *) Update field of a record. |
|
public |
async updateRecord(record: *): * Update an existing record. |
Static Public Methods
public static create(storage: *, search: *, Class: *): * source
Helper creation method
Params:
Name | Type | Attribute | Description |
storage | * | ||
search | * | ||
Class | * |
Return:
* |
Public Constructors
Public Members
Public Methods
public async createRecord(record: *): * source
Add a new record to collection.
Params:
Name | Type | Attribute | Description |
record | * |
Return:
* |
public async deleteRecord(record: *): * source
Delete a record from collection
Params:
Name | Type | Attribute | Description |
record | * |
Return:
* |
public readRecord(record: *): * source
Read an existing record.
Params:
Name | Type | Attribute | Description |
record | * |
Return:
* |
public async searchRecords(query: *): {"results": *} source
Search for records in collection using query.
Params:
Name | Type | Attribute | Description |
query | * |
Return:
{"results": *} |
public stripRecord(record: *, extra: *[]): * source
Strips a record to return as search result.
Params:
Name | Type | Attribute | Description |
record | * | ||
extra | *[] |
|
Return:
* |
public updateField(record: *, field: *, value: *) source
Update field of a record.
Override this to inject custom processing rules.
Params:
Name | Type | Attribute | Description |
record | * | ||
field | * | ||
value | * |
public async updateRecord(record: *): * source
Update an existing record.
Params:
Name | Type | Attribute | Description |
record | * |
Return:
* |