Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DBManager<T>

class DBManager is used to manager reading or writing to system db. the type T must be implements interface ISerializable, reference Account or CurrencyStats

class

DBManager

Type parameters

Hierarchy

  • DBManager

Index

Constructors

constructor

  • new DBManager(tblname: u64, owner: u64, scope: u64): DBManager
  • create a table to persistent data.

    Parameters

    • tblname: u64

      the table name

    • owner: u64

      the owner of the table, who can read and write the table, anyone else is read-only. meanwhile, the owner should pay for storing data if need.

    • scope: u64

      the scope of rows, if you write a row with scope A, then you must read the row with scope A too, otherwise you get nothing.

    Returns DBManager

Properties

_items_vector

_items_vector: DataItem<T>[]

_owner

_owner: u64

_scope

_scope: u64

_tblname

_tblname: u64

Methods

emplace

  • emplace(payer: u64, obj: T): void
  • insert a new record to database.

    Parameters

    • payer: u64

      an account_name, who pays for the storing action.

    • obj: T

      the data to be sotred.

    Returns void

erase

  • erase(obj: T): void
  • remove a record from database.

    Parameters

    • obj: T

      data to be removed.

    Returns void

get

  • get(primary: u64, out: T): boolean
  • read a record form database.

    Parameters

    • primary: u64

      the primary key of data

    • out: T

      the data struct if success.

    Returns boolean

    true if the primary key exists, otherwise false.

getCode

  • getCode(): u64

getScope

  • getScope(): u64

Private loadObjectByPrimaryIterator

  • loadObjectByPrimaryIterator(itr: i32, out: T): void

modify

  • modify(payer: u64, newobj: T): void
  • update a row.

    Parameters

    • payer: u64

      account name who pays for the updating action.

    • newobj: T

      the updated data to be stored.

    Returns void

Generated using TypeDoc