@@ -11,37 +11,28 @@ namespace margelo::nitro::rnnitrosqlite {
1111class HybridNitroSQLiteQueryResult : public HybridNitroSQLiteQueryResultSpec {
1212public:
1313 HybridNitroSQLiteQueryResult () : HybridObject(TAG) {}
14- HybridNitroSQLiteQueryResult (SQLiteQueryResults results,
15- std::optional<double > insertId,
16- double rowsAffected,
14+ HybridNitroSQLiteQueryResult (SQLiteQueryResults results, std::optional<double > insertId, double rowsAffected,
1715 std::optional<SQLiteQueryTableMetadata> metadata)
18- : HybridObject(TAG),
19- _insertId (insertId),
20- _rowsAffected(rowsAffected),
21- _results(std::move(results)),
22- _metadata(metadata) {
16+ : HybridObject(TAG), _insertId(insertId), _rowsAffected(rowsAffected), _results(std::move(results)), _metadata(metadata) {
2317 if (_results.empty ()) {
2418 // Empty rows: empty vector, length 0, item callback always returns null
2519 auto emptyItem = [](double /* idx */ ) -> std::shared_ptr<Promise<std::optional<SQLiteQueryResultRow>>> {
26- return Promise<std::optional<SQLiteQueryResultRow>>::async (
27- []() -> std::optional<SQLiteQueryResultRow> { return std::nullopt ; });
20+ return Promise<std::optional<SQLiteQueryResultRow>>::async ([]() -> std::optional<SQLiteQueryResultRow> { return std::nullopt ; });
2821 };
2922 _rows = NitroSQLiteQueryResultRows (SQLiteQueryResults{}, 0.0 , std::move (emptyItem));
3023 return ;
3124 }
3225
3326 auto rows = _results;
34- auto itemFunction =
35- [rows](double idx) -> std::shared_ptr<Promise<std::optional<SQLiteQueryResultRow>>> {
36- return Promise<std::optional<SQLiteQueryResultRow>>::async (
37- [rows, idx]() -> std::optional<SQLiteQueryResultRow> {
38- const auto index = static_cast <size_t >(idx);
39- if (index >= rows.size ()) {
40- return std::nullopt ;
41- }
42- return rows[index];
43- });
44- };
27+ auto itemFunction = [rows](double idx) -> std::shared_ptr<Promise<std::optional<SQLiteQueryResultRow>>> {
28+ return Promise<std::optional<SQLiteQueryResultRow>>::async ([rows, idx]() -> std::optional<SQLiteQueryResultRow> {
29+ const auto index = static_cast <size_t >(idx);
30+ if (index >= rows.size ()) {
31+ return std::nullopt ;
32+ }
33+ return rows[index];
34+ });
35+ };
4536
4637 const auto length = static_cast <double >(rows.size ());
4738 _rows = NitroSQLiteQueryResultRows (std::move (rows), length, std::move (itemFunction));
@@ -52,7 +43,7 @@ class HybridNitroSQLiteQueryResult : public HybridNitroSQLiteQueryResultSpec {
5243 double _rowsAffected;
5344 SQLiteQueryResults _results;
5445 std::optional<NitroSQLiteQueryResultRows> _rows;
55- std::optional<SQLiteQueryTableMetadata>_metadata;
46+ std::optional<SQLiteQueryTableMetadata> _metadata;
5647
5748public:
5849 // Properties
0 commit comments