[]
        
(Showing Draft Content)

GC.Data.DataManager

Class: DataManager

GC.Data.DataManager

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DataManager()

Represents the data manager.

example

// Create a data manager
var dataManager = new GC.Data.DataManager();

Properties

relationships

relationships: IRelationship[]

Represents the relationship array. Each relationship includes the following field,

property sourceTable - The source table.

property sourceFieldName - The field name of the source table.

property sourceRelationshipName - The relationship name which can be used in source table.

property targetTable - The target table.

property targetFieldName - The field name of the target table.

property targetRelationshipName - The relationship name which can be used in target table.


tables

tables: ITables

Represents the table collection. Its key is table name, and value is GC.Data.Table instance.

Methods

addRelationship

addRelationship(sourceTable, sourceFieldName, sourceRelationshipName, targetTable, targetFieldName, targetRelationshipName): IRelationship

Adds a relationship into the data manager.

example

// Add relationship between products table and categories table
dataManager.addRelationship(productTable, "categoryId", "categories", categoriesTable, "id", "products");

Parameters

Name Type Description
sourceTable Table The source table, which foreign key is target table's primary key.
sourceFieldName string The source field name.
sourceRelationshipName string The source relationship name.
targetTable Table The target table, which primary key is source table's foreign key.
targetFieldName string The target field name.
targetRelationshipName string The target relationship name.

Returns

IRelationship

Returns the relationship.


addTable

addTable(name, dataSourceOption): Table

Add a table into the data manager.

example

// Add a sample table to read data
var tableName = "products";
var dataSourceOption = {
     remote: {
        read: {
            url: "https://demodata.mescius.io/northwind/api/v1/orders"
        }
    },
    schema: {
        columns: {
            orderId: {dataName: "id"},
            orderDate: {dataType: "date", dataPattern: "yyyy-MM-dd hh:mm:ss.000"},
            requiredDate: {dataType: "date"},
            shippedDate: {dataType: "date"},
            shipVia: {dataMap: {1: "Speedy Express", 2: "United Package", 3: "Federal Shipping"}}
        }
    }
};
var dataManager = new GC.Data.DataManager();
var productTable = dataManager.addTable(tableName, dataSourceOption);

Parameters

Name Type Description
name string The table name.
dataSourceOption IDataSourceOption The data source option for creating a table, which contains the following properties.

Returns

Table

Returns the table.


removeRelationship

removeRelationship(name): void

Removes a relationship from the data manager by source relationship name.

example

// Remove a relationship from the data manager by source relationship name
dataManager.removeRelationship("categories");

Parameters

Name Type Description
name string The source relationship name.

Returns

void


removeTable

removeTable(name): void

Removes a table from the data manager.

example

// Remove a table from data manager by table name
dataManager.removeTable("products");

Parameters

Name Type Description
name string The table name.

Returns

void