1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_DISTRIBUTED_DATA_GDB_JS_NAPI_GDB_TRANSACTION_H 16 #define OHOS_DISTRIBUTED_DATA_GDB_JS_NAPI_GDB_TRANSACTION_H 17 18 #include <functional> 19 #include <list> 20 #include <memory> 21 #include <mutex> 22 23 #include "gdb_transaction.h" 24 #include "js_proxy.h" 25 #include "js_uv_queue.h" 26 #include "napi/native_api.h" 27 #include "napi/native_common.h" 28 #include "napi/native_node_api.h" 29 30 namespace OHOS::GraphStoreJsKit { 31 using Transaction = DistributedDataAip::Transaction; 32 class GdbTransactionProxy final : public GraphStoreJsKit::JSProxy<Transaction> { 33 public: 34 GdbTransactionProxy() = default; 35 ~GdbTransactionProxy(); 36 explicit GdbTransactionProxy(std::shared_ptr<Transaction> gdbTransaction); 37 static void Init(napi_env env, napi_value exports); 38 static napi_value NewInstance(napi_env env, std::shared_ptr<Transaction> value); 39 40 private: 41 static napi_value Initialize(napi_env env, napi_callback_info info); 42 static napi_value Read(napi_env env, napi_callback_info info); 43 static napi_value Write(napi_env env, napi_callback_info info); 44 static napi_value Commit(napi_env env, napi_callback_info info); 45 static napi_value Rollback(napi_env env, napi_callback_info info); 46 }; 47 } // namespace OHOS::GraphStoreJsKit 48 #endif