Table entity class

This class models database tables and manages the collection and table names of columns. You can also support transactions to commit or roll back changes.

Hierarchy (view full)

Implements

Constructors

  • Creates a table entity with a given name.

    Parameters

    • name: string

      Table name.

    Returns MetaTable

Properties

_guid: string

Unique identifier of the object (GUID). Uniquely identifies the object.

_metaSet: MetaSet

Metaset to which the entity belongs.

_name: string

The name of the element, which acts as a unique identifier for the MetaElement.

_type: Function

The generator function of the object. The function used when the object was created.

Collection of columns in the table.

Data (low) collection of entities.

tableName: string

Indicates the name of the table.

_NS: string

Indicates the namespace.

'Meta'
_PARAM: []

List of parameters used for the constructor.

['name']
_UNION: []

List of implemented interfaces.

[IElement]

Methods

  • Creates and sets rows for a given entity.

    Parameters

    • entity: BaseEntity

      The entity to be built.

    • callback: Function

      Callback to be called after row generation.

    • items: string[]

      Row name to select, [], or full selection when undefined.

    Returns BaseEntity

    The created entity.

  • Read the entity according to the given option.

    Parameters

    • entity: BaseEntity

      Destination entity.

    • option: number

      Read option.

    Returns any

  • Reads schema information from a given object.

    Parameters

    • obj: object

      Destination object.

    • OptionalcreateRow: boolean

      Whether to create a column with a row name if there is no column (default: false)

    • Optionalorigin: object

      Original object.

    Returns any

  • Commit all changes to the current object. Permission to change: commit

    Returns void

  • Initializes all data in the entity.

    Returns void

  • Creates and returns a deep copy of the current object.

    Returns this

    This is a replica of the current object.

  • Copy the cols column name after the callback.

    Parameters

    • filter: Function

      The filter function that selects the column.

    • cols: string[]

      List of column names to copy.

    Returns this

    The copied meta table object.

  • Copy the cols column name after performing callback.

    Parameters

    • Rest...cols: any[]

      List of column names to copy.

    Returns this

    The copied meta table object.

  • Copy the target column.

    Parameters

    • filter: string[]

      The filter function that selects the column.

    Returns this

    The copied meta table object.

  • Compare the current object with the specified object.

    Parameters

    • target: object

      the object to be compared to.

    Returns boolean

    Returns whether the two objects are the same.

  • Returns a list of changes to the current object.

    Returns object[]

    This is a changed list.

  • Returns objects in serialized form according to specific options. Circular references are replaced by values of '$ref'.

    Parameters

    • OptionalvOpt: number

      Import option. (Default: 0)

      • 0 : Reference structure (_guid: Yes, $ref: Yes)
      • 1: Redundant structure (_guid: Yes, $ref: Yes)
      • 2: Non-tidal rescue (_guid: No, $ref: No)
    • Optionalowned: object | object[]

      Top objects that currently own the object. (Default: {})

    Returns object

    Serialized object.

    const serializedObject = table.getObject(2);
    
  • Returns the creators of the current object and all the creators of the prototype chain to the array.

    Returns Function[]

    Returns the array of generator functions.

    const types = obj.getTypes();
    console.log(types); // [Function: MetaObject]
  • Returns the value of the column as a MetaRow type object.

    Returns MetaRow

    The MetaRow object with the value of the column set.

  • Verify that the current object is an instance of the specified type (including _UNION)

    Parameters

    • target: string | object

      The type of object to be checked (object or string).

    Returns boolean

    Returns whether it is an instance of the specified type.

  • Gets the given object to the current entity. Initializes existing data and loads new data.

    Parameters

    • obj: string | object

      the object to be imported.

    • Optionalparse: Function

      parser function. (Optional)

    Returns void

  • Merges the given entity with the current entity.

    Parameters

    • target: BaseEntity

      Destination entity to merge.

    • option: number

      Merge option. (TODO: type definition required)

    • OptionalmatchType: boolean

      Whether or not a row validation exists. (Default: false)

    Returns void

  • Creates and returns a new row that matches the column structure.

    Returns MetaRow

    The MetaRow object created.

  • Outputs the current entity as a serialized string.

    Parameters

    • vOpt: number

      Optional. (0, 1, 2)

    • Optionalstringify: Function

      This is a custom parser function. (Optional)

    • Optionalspace: string

      A blank string to use in the output. (Optional)

    Returns string

    Serialized string.

  • Reads the given object as an entity. Follow JSON schema rules.

    Parameters

    • obj: object

      object to be read.

    • option: number

      Read option. (Default: 3) (TODO: type definition required)

    Returns void

    var schema1 = { 
    table: {
    columns: {},
    rows: {}
    }
    };

    var schema1 = {
    columns: {...},
    rows: {}
    };
  • Reads only rows that exist on a given object.

    Parameters

    • obj: object

      The object to be read.

    Returns void

  • Reads the given schema object as the current entity.

    Parameters

    • obj: object

      Schema object to read.

    • OptionalcreateRow: boolean

      If true, add columns by row[0] (default: false)

    Returns void

  • Rolls back all changes to the current object. Cancel Changes: rollback

    Returns void

  • Initializes the entity's columns and data.

    Returns void

  • Query rows according to the given callback function.

    Parameters

    • filter: Function

      A callback function that defines the query conditions.

    Returns MetaView

    This is the searched entity.

  • Query rows that meet the given filter conditions.

    Parameters

    • filter: string[]

      Filter conditions.

    • Rest...cols: any[]

      The name of the column to be set for the filter.

    Returns MetaView

    This is the searched entity.

  • Query rows that meet the given filter conditions.

    Parameters

    • filter: string[]

      Filter conditions.

    • Rest...cols: any[]

      The name of the column to be set for the filter.

    Returns MetaView

    This is the searched entity.

  • Enquires rows that match the specified column.

    Parameters

    • Rest...cols: any[]

      column specification.

    Returns MetaView

    This is the searched entity.

  • Reflects a given serialized object to the current object. This action initializes the object.

    Parameters

    • oGuid: object

      Object of the guid type to serialize.

    • Optionalorigin: object

      The source object setting the current object. (Default: oGuid)

    Returns any

  • Set the MetaRow value to the value in the column.

    Parameters

    • row: MetaRow

      MetaRow object to set.

    Returns void

  • Validates the MetaColumn included in the columns collection.

    • Validates the value based on required properties and constructs.

    Returns boolean

    Returns the validation results of the entire column.

  • Returns the current entity by converting it to an object of schema type.

    Parameters

    • OptionalvOpt: number

      Optional. (Default: 0)

    Returns object

    The object of the schema type.

  • Returns data from the current entity by converting it to an object of schema type.

    Parameters

    • OptionalvOpt: number

      Optional. (Default: 0)

    Returns object

    The object of the schema type.

  • Returns the schema of the current entity by converting it to an object of schema type.

    Parameters

    • OptionalvOpt: number

      Optional. (Default: 0)

    Returns object

    The object of the schema type.

  • Converts a given serialization object to a schema object.

    Parameters

    • oGuid: object

      object obtained from getObject().

    Returns object

    The transformed schema object.