MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / GetRowJS

Method GetRowJS

src/util/row-builder.cpp:11–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 reprepare_count(-1) {}
10
11Napi::Value RowBuilder::GetRowJS(Napi::Env env, sqlite3_stmt* handle, bool safe_ints) {
12 int current_reprepare_count = sqlite3_stmt_status(handle, SQLITE_STMTSTATUS_REPREPARE, false);
13 if (current_reprepare_count != reprepare_count) {
14 column_count = sqlite3_column_count(handle);
15 std::vector<napi_value> keys(column_count);
16 for (int i = 0; i < column_count; ++i) {
17 keys[i] = InternalizedFromUtf8(env, sqlite3_column_name(handle, i), -1);
18 }
19 create_row = Napi::Persistent(
20 SafeCall(env, row_factory.Value(), env.Undefined(), column_count, keys.data())
21 .As<Napi::Function>()
22 );
23 reprepare_count = current_reprepare_count;
24 }
25
26 napi_value value_storage[16];
27 std::vector<napi_value> extra_values;
28 napi_value* values = value_storage;
29 if (column_count > 16) {
30 extra_values.resize(column_count);
31 values = extra_values.data();
32 }
33 for (int i = 0; i < column_count; ++i) {
34 values[i] = Data::GetValueJS(env, handle, i, safe_ints);
35 }
36
37 return SafeCall(env, create_row.Value(), env.Undefined(), column_count, values);
38}
39
40Napi::Value RowBuilder::GetRawRowJS(Napi::Env env, sqlite3_stmt* handle, bool safe_ints) {
41 column_count = sqlite3_column_count(handle);

Callers 1

GetFlatRowJSFunction · 0.80

Calls 3

InternalizedFromUtf8Function · 0.85
SafeCallFunction · 0.85
GetValueJSFunction · 0.85

Tested by

no test coverage detected