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

Function GetExpandedRowJS

src/util/data.cpp:81–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 }
80
81 Napi::Value GetExpandedRowJS(Napi::Env env, sqlite3_stmt* handle, bool safe_ints) {
82 Napi::Object row = Napi::Object::New(env);
83 int column_count = sqlite3_column_count(handle);
84 for (int i = 0; i < column_count; ++i) {
85 const char* table_raw = sqlite3_column_table_name(handle, i);
86 Napi::String table = InternalizedFromUtf8(env, table_raw == NULL ? "$" : table_raw, -1);
87 Napi::String column = InternalizedFromUtf8(env, sqlite3_column_name(handle, i), -1);
88 Napi::Value value = Data::GetValueJS(env, handle, i, safe_ints);
89 if (row.HasOwnProperty(table)) {
90 row.Get(table).As<Napi::Object>().Set(column, value);
91 } else {
92 Napi::Object nested = Napi::Object::New(env);
93 row.Set(table, nested);
94 nested.Set(column, value);
95 }
96 }
97 return row;
98 }
99
100 Napi::Value GetFlatRowJS(Napi::Env env, Statement* stmt, sqlite3_stmt* handle, bool safe_ints) {
101 return stmt->GetRowBuilder().GetRowJS(env, handle, safe_ints);

Callers 1

GetRowJSFunction · 0.85

Calls 2

InternalizedFromUtf8Function · 0.85
GetValueJSFunction · 0.85

Tested by

no test coverage detected