Class BaseEntityAbstract

Primary entity class (top)

This class models entities in the database (e.g., tables, views, etc.), and manages column and raw data. It implements various interfaces to support transactions, serialization, schema conversion, and more.

Hierarchy (view full)

Implements

Constructors

  • Creates an entity with a given name.

    Parameters

    • name: string

    Returns BaseEntity

    • The entity name.

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.

The collection of items (properties) for the entity.

Data (low) collection of entities.

_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

  • Initializes all data in the entity.

    Returns void

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

    Returns this

    This is a replicated entity object.

  • Creates and returns a copy of the current entity.

    Parameters

    • Rest...args: any[]

    Returns this

    The copied entity 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 objects in serialized form according to specific options; cyclic references are replaced by $ref values.

    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 = entity.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

  • 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.

  • Initialize the current object using the serialized object. In this process, the object is initialized, and the state of the object is restored based on the serialized object (oGuid).

    Parameters

    • oGuid: object

      serialized object.

    • Optionalorigin: object

      Original object. Default is '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.