UNPKG

@cordova-plugin-agconnect/clouddb

Version:
100 lines (90 loc) 2.92 kB
/* * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. */ import { CloudDBZoneAccessProperty, CloudDBZoneSyncProperty, Operation, QueryOperation } from "./enums"; /** * Transaction interface describes a transaction. * The transaction provides the query, upsert, and delete methods to add, * delete, modify, and query data in the Cloud DB zone on the cloud. */ export interface Transaction { className: string, operation: Operation, data: any[] | QueryObject } /** * This interface defines result object from the runTransaction() method. * If the transaction array contains a query, than result of query will be * returned on queryResult field, otherwise this field will be empty. */ export interface TransactionResult { isSuccessful: boolean, queryResult: {} } /** * This interface is used to create a CloudDBZoneConfig object and configure * Cloud DB zone information such as the synchronization property, * access property, encrypted storage property, and data persistency property. */ export interface CloudDBZoneConfig { cloudDBZoneName: string, accessProperty: CloudDBZoneAccessProperty, syncProperty: CloudDBZoneSyncProperty, capacity?: number, persistenceEnabled?: boolean, isEncrypted: boolean, key?: string, reKey?: string } /** * This interface defines object type which on the query will be executed and query conditions. */ export interface QueryObject { className: string, queryElements: QueryElement[] } /** * This interface defines a single query condition. */ export interface QueryElement { operation: QueryOperation, fieldName?: string, offset?: number, value?: any } /** * CloudDBZoneSnapshot interface is used to describe the queried snapshot data, * including full object sets, added and modified object sets, and newly deleted object sets. */ export interface CloudDBZoneSnapshotData { hasPendingWrites: boolean, isFromCloud: boolean, snapshotObjects: any[], upsertedObjects: any[], deletedObjects: any[] } /** * CloudDBZoneSnapshot interface is used to including full object sets, * added and modified object sets, and newly deleted object sets. */ export interface CloudDBZoneSnapshot extends CloudDBZoneSnapshotData { } /** * CloudDBZoneSnapshot interface is used to describe the queried snapshot data. */ export interface CloudDBZoneSubscribeSnapshot { id: string, data?: CloudDBZoneSnapshotData, error?: AGCCloudDBException } /** * Exception base interface of Cloud DB, which is inherited from AGCException. * AGConnectCloudDBException provides methods for developers to obtain exception information, * including error codes and detailed error information. * @param message An error information. * @param code An error code. */ export interface AGCCloudDBException { message: string, code: number }