Constructor
new Actor(modelSchemaopt, repositoryopt)
Properties:
Name | Type | Description |
---|---|---|
repository |
any
|
A reference to a storage layer client of your choosing or undefined . |
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
modelSchema |
Schema
|
<optional> |
The instance of the associated Model's JSON Schema definition. |
repository |
any
|
<optional> |
An optional reference to a storage layer client of your choosing. |
Example
import { Actor, Schema } from 'hive-io'
import ExampleSchema from '../schemas/ExampleSchema.json'
class ExampleActor extends Actor {
async perform (model, action) {
// Do something interesting with the data
}
}
// Proxy<ExampleActor>
export default new Proxy(ExampleActor, {
construct: async function (ExampleActor, argsList) {
const example = await new Schema(ExampleSchema)
return new ExampleActor(example, argsList[0])
}
})
Methods
assign(model, payloadopt) → {Object}
Method used to generate the materialized view of a specified
model
from specified payload
. Arrays on the model
are completely replaced by the provided payload
currently.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
model |
Object
|
The instance of a model to receive new data. | ||
payload |
Object
|
<optional> |
{} | The payload to apply to the model. |
Returns:
- Type:
-
Object
The updated instance of the model.
(async) perform(model, actionopt) → {Object}
Method that carries out the actions specified in the
action
to the specified model
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
model |
Object
|
An instance of the model associated with the received data generated from replay .
|
|
action |
Object
|
<optional> |
An optional FSA Object literal containing the Model's type and optional meta and payload .
|
Returns:
- Type:
-
Object
An Object literal containing the latest materialized view of the model.
(async) replay(aggregate) → {Object}
Method that carries out the historical events or model snapshot specified in the
aggregate
.
Parameters:
Name | Type | Description |
---|---|---|
aggregate |
Object
|
Array.<Object>
|
The historical events or model snapshot specified. |
Returns:
- Type:
-
Object
An Object literal containing the latest materialized view of the model.