1 /* 2 * Copyright (c) 2023 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 16 #ifndef KV_STORE_EXECUTOR_H 17 #define KV_STORE_EXECUTOR_H 18 19 #include <string> 20 21 #include "check_common.h" 22 23 namespace DocumentDB { 24 class KvStoreExecutor { 25 public: 26 virtual ~KvStoreExecutor() = default; 27 28 virtual int StartTransaction() = 0; 29 virtual int Commit() = 0; 30 virtual int Rollback() = 0; 31 32 virtual int PutData(const std::string &collName, Key &key, const Value &value, bool isNeedAddKeyType = true) = 0; 33 virtual int InsertData(const std::string &collName, Key &key, const Value &value, bool isNeedAddKeyType = true) = 0; 34 virtual int GetDataByKey(const std::string &collName, Key &key, Value &value) const = 0; 35 virtual int GetDataById(const std::string &collName, Key &key, Value &value) const = 0; 36 virtual int GetDataByFilter(const std::string &collName, Key &key, const JsonObject &filterObj, 37 std::pair<std::string, std::string> &values, int isIdExist) const = 0; 38 virtual int DelData(const std::string &collName, Key &key) = 0; 39 40 virtual int CreateCollection(const std::string &name, const std::string &option, bool ignoreExists) = 0; 41 virtual int DropCollection(const std::string &name, bool ignoreNonExists) = 0; 42 virtual bool IsCollectionExists(const std::string &name, int &errCode) = 0; 43 44 virtual int SetCollectionOption(const std::string &name, const std::string &option) = 0; 45 virtual int CleanCollectionOption(const std::string &name) = 0; 46 }; 47 } // namespace DocumentDB 48 #endif // KV_STORE_EXECUTOR_H