ConvectorModel<T>

This class is intended to be inherited by all the models of the application.

It provides the underlying communication with the BaseStorage.

Type parameters

Hierarchy

  • ConvectorModel

Index

Constructors

constructor

Properties

id

id: string

This field is Required and Validated using a string schema

Represents the key used to store the model in the blockchain

Abstract type

type: string

This field must be provided by the extender class.

It should be Required and ReadOnly

We normally use a domain name patter for type names, i.e.: io.worldsibu.example.user

Methods

clone

  • clone(): T

delete

  • delete(): Promise<void>
  • Delete a model and persist the changes into the blockchain.

    Notice that there's no such a concept as delete in the blockchain, so what this does is to remove all the reachable references to the model.

    Returns Promise<void>

fetch

  • fetch(): Promise<void>

history

save

  • save(): Promise<void>

toJSON

  • toJSON(skipEmpty?: boolean): object

update

  • update(content: object): Promise<void>

Static getAll

  • getAll<T>(this: object, type?: string): Promise<T[]>

Static getOne

  • getOne<T>(this: object, id: string, type?: object): Promise<T>
  • Fetch one model by its id and instantiate the result

    Type parameters

    Parameters

    • this: object

      The extender type

    • id: string

      The ID used to fetch the model

    • Optional type: object

      The type to use for instantiation, if not provided, the extender type is used

    Returns Promise<T>

Static query

  • query<T>(type: object, ...args: any[]): Promise<T | T[]>
  • Runs a query on the storage layer

    Type parameters

    • T

    Parameters

    • type: object

      The type to use for instantiation, if not provided, the extender type is used

    • Rest ...args: any[]

      The query params, this is passed directly to the current storage being used

    Returns Promise<T | T[]>

Static schema