Class: Model
Base class from which all property models inherit.
description
Provides helper methods to load the property model data from an object and to get a mapping of all the keys available in the given model.• new Model()
Defined in
▸ _custom_mapping(
props
, data
): void
Parameters
Name | Type |
---|---|
props | object |
data | object |
Returns
void
Defined in
Parameters
Name | Type |
---|---|
cls | any |
Returns
Defined in
▸ from_properties(
props
): any
Initialize the model from an object representation.
description
When provided with an object of properties, it will find the matching keys within it and fill the model fields with the values from the object.It ignores non-matching keys - i.e. doesn't require filtering of the properties' object before the model is fed with the data. Thus, several models can be initialized from the same object and all models will only load their own data.
Parameters
Name | Type |
---|---|
props | object |
Returns
any
Defined in
▸ keys():
any
example
import { props } from "yajsapi"
const { Field, Model } = props;
export class NodeInfo extends Model {
name: Field = new Field({ metadata: { key: "golem.node.id.name" } });
subnet_tag: Field = new Field({
metadata: { key: "golem.node.debug.subnet" },
});
}
new NodeInfo().keys().name()
// Output: 'golem.node.id.name'
Returns
any
a mapping between the model's field names and the property keys
Defined in
Last modified 1yr ago