UNPKG

@cordova-plugin-agconnect/clouddb

Version:
67 lines (66 loc) 2.21 kB
"use strict"; /* * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. */ Object.defineProperty(exports, "__esModule", { value: true }); const enums_1 = require("./enums"); class AGCCloudDBTransaction { constructor() { this.transactions = []; } /** * Initializes an AGCCloudDBTransaction object. * @param zoneName Cloud DB zone name */ static function() { return new AGCCloudDBTransaction(); } /** * Writes a group of objects to the Cloud DB zone in a transaction in batches. * @param className A class object that represents the object type entity class defined by the developer. * @param data A list, represents the data to be written. */ executeUpsert(className, data) { this.transactions.push({ operation: enums_1.Operation.UPSERT, className: className, data: data }); return this; } /** * Deletes a group of objects from the Cloud DB zone in a transaction in batches. * @param className A class object that represents the object type entity class defined by the developer. * @param data A list, represents the data to be deleted. */ executeDelete(className, data) { this.transactions.push({ operation: enums_1.Operation.DELETE, className: className, data: data }); return this; } /** * Queries a set of objects that meet specific conditions from the Cloud DB zone on the cloud in a transaction. * @param className A class object that represents the object type entity class defined by the developer. * @param data A QueryObject object, which indicates the query condition. */ executeQuery(className, data) { this.transactions.push({ operation: enums_1.Operation.QUERY, className: className, data: data }); return this; } /** * This method is used to build the Transaction list. * @returns Transaction list. */ build() { Object.freeze(this); return this.transactions; } } exports.default = AGCCloudDBTransaction;