@@ -2079,6 +2079,8 @@ void StatementSync::All(const FunctionCallbackInfo<Value>& args) {
2079
2079
args.GetReturnValue ().Set (Array::New (isolate, rows.data (), rows.size ()));
2080
2080
}
2081
2081
2082
+ void Statement::Iterate (const FunctionCallbackInfo<Value>& args) {}
2083
+
2082
2084
void StatementSync::Iterate (const FunctionCallbackInfo<Value>& args) {
2083
2085
StatementSync* stmt;
2084
2086
ASSIGN_OR_RETURN_UNWRAP (&stmt, args.This ());
@@ -2120,6 +2122,39 @@ void StatementSync::Iterate(const FunctionCallbackInfo<Value>& args) {
2120
2122
args.GetReturnValue ().Set (iter->object ());
2121
2123
}
2122
2124
2125
+ void Statement::Get (const FunctionCallbackInfo<Value>& args) {
2126
+ StatementSync* stmt;
2127
+ ASSIGN_OR_RETURN_UNWRAP (&stmt, args.This ());
2128
+ Environment* env = Environment::GetCurrent (args);
2129
+ THROW_AND_RETURN_ON_BAD_STATE (
2130
+ env, stmt->IsFinalized (), " statement has been finalized" );
2131
+ Isolate* isolate = env->isolate ();
2132
+ int r = sqlite3_reset (stmt->statement_ );
2133
+ CHECK_ERROR_OR_THROW (isolate, stmt->db_ .get (), r, SQLITE_OK, void ());
2134
+
2135
+ if (!stmt->BindParams (args)) {
2136
+ return ;
2137
+ }
2138
+
2139
+ Local<Promise::Resolver> resolver;
2140
+ if (!Promise::Resolver::New (env->context ()).ToLocal (&resolver)) {
2141
+ return ;
2142
+ }
2143
+
2144
+ auto task = [stmt]() -> int {
2145
+
2146
+ };
2147
+
2148
+ auto after = [env, isolate, stmt](int result, Local<Promise::Resolver> resolver) {
2149
+
2150
+ };
2151
+
2152
+ auto * work = new SQLiteAsyncWork<std::vector<Row>>(
2153
+ env, stmt->db_ .get (), resolver, task, after);
2154
+ work->ScheduleWork ();
2155
+ args.GetReturnValue ().Set (resolver->GetPromise ());
2156
+ }
2157
+
2123
2158
void StatementSync::Get (const FunctionCallbackInfo<Value>& args) {
2124
2159
StatementSync* stmt;
2125
2160
ASSIGN_OR_RETURN_UNWRAP (&stmt, args.This ());
@@ -2353,8 +2388,6 @@ using RowArray = std::vector<sqlite3_value*>;
2353
2388
using RowObject = std::vector<std::pair<std::string, sqlite3_value*>>;
2354
2389
using Row = std::variant<RowArray, RowObject>;
2355
2390
2356
- void Statement::Get (const FunctionCallbackInfo<Value>& args) {}
2357
-
2358
2391
void Statement::All (const FunctionCallbackInfo<Value>& args) {
2359
2392
Statement* stmt;
2360
2393
ASSIGN_OR_RETURN_UNWRAP (&stmt, args.This ());
0 commit comments