Class OperationFields

Operation fields containing application data.

Example

import { OperationFields, encodeOperation } from 'p2panda-js';

const fields = new OperationFields({
name: 'Panda Party!',
});

fields.insert(
'venue',
'relation',
'002078619bd4beff4bec4d4ccf75a7a5c25bf5d3c37fbd051a45debf1f17a1f75230'
);

const operation = encodeOperation({
schemaId: 'events_00203ebb383f195f2923d51ac9929a8dbf7fba65dcddff874dfbe5ef131362696636',
fields,
});

Hierarchy

  • OperationFields

Constructors

Properties

Methods

Constructors

  • Creates a new instance of OperationFields.

    Parameters

    • Optional fields: EasyValues

      "Easy field values" to populate the operation with basic data types. This can be used to easily create operation fields, even when there is no schema at hand. Please note that only unambigious field types like "str", "int", "float" and "bool" can be used here

    Returns OperationFields

    OperationFields instance

    Example

    import { OperationFields } from 'p2panda-js';

    const fields = new OperationFields({
    hasDate: true,
    latestYear: 2002,
    });

Properties

__internal: OperationFields$1

Methods

  • Inserts a new field.

    Parameters

    • fieldName: string

      Name of the field, needs to match schema

    • fieldType: FieldType

      Operation field type

    • value: OperationValueArg

      Actual user data

    Returns void

    Example

    import { OperationFields } from 'p2panda-js';

    const fields = new OperationFields();
    fields.insert('venue', 'relation', '002078619bd4beff4bec4d4ccf75a7a5c25bf5d3c37fbd051a45debf1f17a1f75230');
  • Gets a value from a field.

    Parameters

    • fieldName: string

      Name of the field, needs to match schema

    Returns OperationValue

    User data

  • Returns the number of fields.

    Returns number

  • Returns true when there are no fields given.

    Returns boolean

Generated using TypeDoc