@cordova-plugin-agconnect/clouddb
Version:
Cordova AGC CloudDB Plugin
117 lines (116 loc) • 7.12 kB
TypeScript
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
*/
import { CloudDBZoneQueryPolicy } from "./enums";
import { CloudDBZoneConfig, CloudDBZoneSnapshot, CloudDBZoneSubscribeSnapshot, QueryObject, Transaction, TransactionResult } from "./interfaces";
export default class AGCCloudDBZone {
private readonly _id;
constructor(id: string);
/**
* Obtains the id of current Cloud DB zone instance.
*/
get id(): string;
/**
* Obtains the current configuration information of Cloud DB zone.
* @returns A CloudDBZoneConfig object.
*/
getCloudDBZoneConfig(): Promise<CloudDBZoneConfig>;
/**
* Writes a group of objects to the current Cloud DB zone in batches.
* @param className Name of the object type.
* @param cloudDBZoneObjectArray Object datas to be written.
* @returns Number of objects that are successfully written.
*/
executeUpsert(className: string, cloudDBZoneObjectArray: any[]): Promise<number>;
/**
* Deletes a group of Cloud DB zone objects whose primary key values are the same as those of the input object list in batches.
* @param className Name of the object type.
* @param cloudDBZoneObjectArray Object datas to be deleted.
* @returns Number of objects that are successfully deleted.
*/
executeDelete(className: string, cloudDBZoneObjectArray: any[]): Promise<number>;
/**
* Queries objects that meet specified conditions in Cloud DB zone and encapsulates the query result set into a CloudDBZoneSnapshot.
* @param queryObject A QueryObject object, which indicates the query condition.
* @param queryPolicy Query policy, which specifies the data source to be queried.
* @returns CloudDBZoneSnapshot object that encapsulates the query result set.
*/
executeQuery(queryObject: QueryObject, queryPolicy: CloudDBZoneQueryPolicy): Promise<CloudDBZoneSnapshot>;
/**
* Queries objects that meet specified conditions in Cloud DB zone and returns the average value of specified fields.
* @param queryObject A QueryObject object, which indicates the query condition.
* @param fieldName Specifies the name of the fields whose average value needs to be calculated in the query object.
* @param queryPolicy Query policy, which specifies the data source to be queried.
* @returns The avarage value.
*/
executeAverageQuery(queryObject: QueryObject, fieldName: string, queryPolicy: CloudDBZoneQueryPolicy): Promise<string>;
/**
* Queries objects that meet specific conditions and returns the sum of data record values of specified fields in the Cloud DB zone.
* @param queryObject A QueryObject object, which indicates the query condition.
* @param fieldName Specifies the name of the fields whose sum value needs to be calculated in the query object.
* @param queryPolicy Query policy, which specifies the data source to be queried.
* @returns The sum result.
*/
executeSumQuery(queryObject: QueryObject, fieldName: string, queryPolicy: CloudDBZoneQueryPolicy): Promise<string>;
/**
* Queries the objects that meet specific conditions and returns the maximum value of the data records in the specified fields in the Cloud DB zone.
* @param queryObject A QueryObject object, which indicates the query condition.
* @param fieldName Specifies the name of the fields whose max value needs to be calculated in the query object.
* @param queryPolicy Query policy, which specifies the data source to be queried.
* @returns The maximum value.
*/
executeMaximumQuery(queryObject: QueryObject, fieldName: string, queryPolicy: CloudDBZoneQueryPolicy): Promise<string>;
/**
* Queries the objects that meet specific conditions in the Cloud DB zone and returns the minimum value of the data records in the designated fields.
* @param queryObject A QueryObject object, which indicates the query condition.
* @param fieldName Specifies the name of the fields whose min value needs to be calculated in the query object.
* @param queryPolicy Query policy, which specifies the data source to be queried.
* @returns The minimum value.
*/
executeMinimalQuery(queryObject: QueryObject, fieldName: string, queryPolicy: CloudDBZoneQueryPolicy): Promise<string>;
/**
* Queries the objects that meet specific conditions in the Cloud DB zone and returns the number of data records of the specified fields.
* @param queryObject A QueryObject object, which indicates the query condition.
* @param fieldName Specifies the name of the fields whose count value needs to be calculated in the query object.
* @param queryPolicy Query policy, which specifies the data source to be queried.
* @returns The number of data result.
*/
executeCountQuery(queryObject: QueryObject, fieldName: string, queryPolicy: CloudDBZoneQueryPolicy): Promise<string>;
/**
* Queries all object data that meets specified conditions in Cloud DB but has not been synchronized to the cloud, and encapsulates the query result set into a CloudDBZoneSnapshot.
* @param queryObject A QueryObject object, which indicates the query condition.
* @returns CloudDBZoneSnapshot object that encapsulates the query result set.
*/
executeQueryUnsynced(queryObject: QueryObject): Promise<CloudDBZoneSnapshot>;
/**
* Executes a specified transaction operation.
* @param transactions You can encapsulate a group of operations in the array,
* and then use this interface to implement the functions of adding, deleting, modifying,
* and querying operations in a transaction.
* @returns An object, which encapsulates the execution status, result,
* and exception information of runTransaction().
* For example, you can call the isSuccessful property based on this
* object to check whether the query operation is successful.
*/
runTransaction(transactions: Transaction[]): Promise<TransactionResult>;
/**
* Registers a listener for a specified object on the device or cloud.
* When the data of the object that is listened on is changed, the registered onSnapshotUpdate event is triggered.
* @param queryObject A QueryObject object, which indicates the query condition.
* @param queryPolicy Query policy, which specifies the data source to be queried.
* @param callback Callback function to be called when listener is triggered.
* @returns A ListenerHandler object that remains valid until the remove() method
* of the ListenerHandler class is explicitly called by the developer.
*/
subscribeSnapshot(queryObject: QueryObject, queryPolicy: CloudDBZoneQueryPolicy, callback: (cloudDBZoneSnapshot: CloudDBZoneSubscribeSnapshot) => void): Promise<ListenerHandler>;
}
declare class ListenerHandler {
private readonly zoneId;
private readonly listenerId;
constructor(zoneId: string, listenerId: string);
/**
* Deregisters the snapshot listener.
*/
remove(): Promise<void>;
}
export {};