@op-engineering/op-sqlite 6.0.1 → 6.0.2-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ #ifndef DBHostObject_h
2
+ #define DBHostObject_h
3
+
4
+ #include "ThreadPool.h"
5
+ #include "types.h"
6
+ #include <ReactCommon/CallInvoker.h>
7
+ #include <any>
8
+ #include <jsi/jsi.h>
9
+ #include <unordered_map>
10
+ #include <vector>
11
+
12
+ namespace opsqlite {
13
+
14
+ namespace jsi = facebook::jsi;
15
+ namespace react = facebook::react;
16
+
17
+ struct ReactiveQuery {
18
+ std::string query;
19
+ std::vector<JSVariant> args;
20
+ std::vector<std::string> tables;
21
+ std::vector<int> rowIds;
22
+ std::shared_ptr<jsi::Value> callback;
23
+ };
24
+
25
+ class JSI_EXPORT DBHostObject : public jsi::HostObject {
26
+ public:
27
+ DBHostObject(jsi::Runtime &rt, std::string &base_path,
28
+ std::shared_ptr<react::CallInvoker> js_call_invoker,
29
+ std::shared_ptr<ThreadPool> thread_pool, std::string &db_name,
30
+ std::string &path, std::string &crsqlite_path,
31
+ std::string &encryption_key);
32
+
33
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt);
34
+
35
+ jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propNameID);
36
+
37
+ void auto_register_update_hook();
38
+
39
+ std::unordered_map<std::string, jsi::Value> function_map;
40
+ std::string base_path;
41
+
42
+ std::shared_ptr<jsi::Value> update_hook;
43
+ std::shared_ptr<react::CallInvoker> jsCallInvoker;
44
+ std::shared_ptr<ThreadPool> thread_pool;
45
+ std::string db_name;
46
+ std::shared_ptr<jsi::Value> update_hook_callback;
47
+ std::shared_ptr<jsi::Value> commit_hook_callback;
48
+ std::shared_ptr<jsi::Value> rollback_hook_callback;
49
+ jsi::Runtime &rt;
50
+ std::vector<std::shared_ptr<ReactiveQuery>> reactive_queries;
51
+ bool has_update_hook_registered = false;
52
+ };
53
+
54
+ } // namespace opsqlite
55
+
56
+ #endif /* DBHostObject_h */
@@ -29,7 +29,7 @@ jsi::Value PreparedStatementHostObject::get(jsi::Runtime &rt,
29
29
  }
30
30
 
31
31
  const jsi::Value &js_params = args[0];
32
- std::vector<JSVariant> params = toVariantVec(rt, js_params);
32
+ std::vector<JSVariant> params = to_variant_vec(rt, js_params);
33
33
 
34
34
  opsqlite_bind_statement(_statement, &params);
35
35