Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IDartDatabaseReader

An interface for DartDatabase. It is used to query records of public table provided by another module. You can get this through IModulePackageManager.queryModuleDatabaseInfo.

api-version

1

user

Hierarchy

  • IDartDatabaseReader

Index

Properties

tableName: string

Methods

  • getColumnNames(): Promise<string[]>
  • Get all columnNames.

    api-version

    1

    user

    Returns Promise<string[]>

    Return column names list from the table name or null.

  • query(projection: string[], where: Record<string, any>): Promise<TableRow[]>
  • Query to execute on its own module

    api-version

    1

    user
    example
    import { IToast, Toast, ModuleContext, IDartDatabase, IModulePackageManager } from "dart-api";
    export function MyComponent(props: {moduleContext:ModuleContext}){
    const context = props.moduleContext;
    const databaseLibrary = context.getSystemLibrary(Context.DART_DATABASE) as IDartDatabase;
    const packageManager = context.getSystemManager(Context.MODULE_PACKAGE_MANAGER) as IModulePackageManager;
    useEffect(() => {
    const message = new Message({
    action: Message.ACTION_USER_INFO_DATABASE_READER,
    category: Message.CATEGORY_DATABASE,
    });
    const columns = ["name", "ip"]
    const where {"name": "Jone"}

    const resolveInfos = packageManager.queryModuleDatabaseInfo(message);
    for (const x of resolveInfos) {
    const reader = x.databaseInfo?.createDatabaseReader(context);
    reader?.query(columns, where)
    .then(r => {
    Toast.show(IToast.TYPE_INFO, null, `${JSON.stringify(r)}`);
    });
    }
    }, []);
    return <>Please implement your code here.</>
    }

    Parameters

    • projection: string[]

      Column information about filtering results.

    • where: Record<string, any>

      Column name and data for filter records.

    Returns Promise<TableRow[]>

    Return results of query.

  • queryDeviceSetting(projection: string[], where: Record<string, any>): Promise<TableRow[]>
  • Query records from the {@link DeviceSettingsTableContracts.TABLE_NAME} table.

    api-version

    1

    user
    example
    import { IToast, Toast, ModuleContext, IDartDatabase, IModulePackageManager, DeviceSettingData, DeviceSettingsTableContracts as DTContracts } from "dart-api";
    export function MyComponent(props: {moduleContext:ModuleContext}){
    const context = props.moduleContext;
    const databaseLibrary = context.getSystemLibrary(Context.DART_DATABASE) as IDartDatabase;
    const packageManager = context.getSystemManager(Context.MODULE_PACKAGE_MANAGER) as IModulePackageManager;
    useEffect(() => {
    const message = new Message({
    action: Message.ACTION_DEVICE_SETTINGS_DATABASE_READER,
    category: Message.CATEGORY_DATABASE,
    });
    const columns = [
    DTContracts.COLUMN_UUID,
    DTContracts.COLUMN_DEVICE_NAME,
    DTContracts.COLUMN_ALIAS_NAME,
    DTContracts.COLUMN_TYPE,
    DTContracts.COLUMN_DATA,
    ];
    const where {[DTContracts.COLUMN_TYPE]: DeviceSettingDataType.DIGITAL_OUTPUT}

    const resolveInfos = packageManager.queryModuleDatabaseInfo(message);
    for (const x of resolveInfos) {
    const reader = x.databaseInfo?.createDatabaseReader(context);
    reader?.queryDeviceSetting(columns, where)
    .then(r => {
    Toast.show(IToast.TYPE_INFO, null, `${JSON.stringify(r)}`);
    });
    }
    }, []);
    return <>Please implement your code here.</>
    }

    Parameters

    • projection: string[]

      Column information about filtering results.

    • where: Record<string, any>

      Column name and data for filter records.

    Returns Promise<TableRow[]>

    Return results of query.

  • queryDeviceSettingWithError(projection: string[], where: Record<string, any>): Promise<{ data?: TableRow[]; error?: CommunicationError }>
  • Query records from the {@link DeviceSettingsTableContracts.TABLE_NAME} table. Returns null if an error occurs.

    api-version

    3

    user

    Parameters

    • projection: string[]

      Column information about filtering results.

    • where: Record<string, any>

      Column name and data for filter records.

    Returns Promise<{ data?: TableRow[]; error?: CommunicationError }>

    Return Fulfills with results of query if the request has been operated successfully, otherwise CommunicationError.

  • Query to execute on its own module. Returns null if an error occurs.

    api-version

    3

    user

    Parameters

    • projection: string[]

      Column information about filtering results.

    • where: Record<string, any>

      Column name and data for filter records.

    Returns Promise<{ data?: TableRow[]; error?: CommunicationError }>

    Return Fulfills with results of query if the request has been operated successfully, otherwise CommunicationError.

Generated using TypeDoc